mathiasbynens / mathiasbynens/dotfiles

Conda virtualenv prompt support

Open
#816 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
31.5k
Forks
8.4k
PR merge metrics
No merged PRs in 30d

Description

I'm trying to include highlighting of the conda virtualenv in the `.bash_prompt` file, but I'm not very familiar with bash and haven't had much success in targeting it. Say this is the desired result for some virtualenv named `temp`;

``` shell
username at host in ~/dotfiles on master [+] < temp >
````

Currently, the conda virtualenv name is prepended to the command prompt. I believe that is the default behavior;

``` shell
(temp)
username at host in ~/dotfiles on master [+]
````

I can't get it to work and this is as far as I got by looking at bash-it's [powerline theme](https://github.com/Bash-it/bash-it/blob/76e4659126014b695ec2f01a14491bce7aa7e2a1/themes/powerline/powerline.base.bash#L55) and [here](https://github.com/jchaps/dotfiles/blob/dac2598dff6919bfed53d8ac0788dd6f10ca365d/system/prompt#L93);

``` shell
# Highlight the Conda environment.
if [[ "$CONDA_DEFAULT_ENV" != "" ]]; then
condaStyle="${white}:$CONDA_DEFAULT_ENV";
else
condaStyle="";
fi;
```

and included in the existing prompt with;
``` shell
PS1+="\[${condaStyle}\]\n"; # conda
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the `.bash_prompt` file and trace how `PS1` is assembled. Check how `CONDA_DEFAULT_ENV` identifies the active Conda environment, then place that value in the prompt format shown in the issue. Done means an active environment such as `temp` appears in angle brackets without the default `(temp)` prefix, while prompts without Conda remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash
Domain
cli
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.