Merge pull request #309 from krischer/conda-prompt-changes

Conda prompt speedup and configuration
pull/22/head
Ben Hilburn 8 years ago committed by GitHub
commit 02cc43ff09

@ -140,13 +140,21 @@ The segments that are currently available are:
##### anaconda ##### anaconda
This segment shows your active anaconda environment. This segment shows your active anaconda environment. It relies on either the
`CONDA_ENV_PATH` or the `CONDA_PREFIX` (depending on the `conda` version)
environment variable to be set which happens when you properly `source
activate` an environment.
*Note: This segment relies on a perl-regex with lookbehind. Special configuration variables:
If `ack` is not available the segment will try to use `grep`.
Recent versions of grep offer a `-P` option to handle such things. | Variable | Default Value | Description |
On OSX, however, you want to install gnu-grep (e.g. via `brew install grep`) |----------|---------------|-------------|
and alias the newly installed `ggrep` to `grep`. Alternatively, `brew install ack`.* |`POWERLEVEL9K_ANACONDA_LEFT_DELIMITER`|"("|The left delimiter just before the environment name.|
|`POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER`|")"|The right delimiter just after the environment name.|
Additionally the following segment specific parameters can be used to customize
it: `POWERLEVEL9K_PYTHON_ICON`, `POWERLEVEL9K_ANACONDA_BACKGROUND`, and
`POWERLEVEL9K_ANACONDA_FOREGROUND`.
##### aws ##### aws

@ -291,13 +291,14 @@ CURRENT_BG='NONE'
# Anaconda Environment # Anaconda Environment
prompt_anaconda() { prompt_anaconda() {
if $(hash ack 2>/dev/null); then # Depending on the conda version, either might be set. This
local active_conda_env=$(where conda | ack -o '(?<=envs/)[\w-]+(?=/bin)') # variant works even if both are set.
else _path=$CONDA_ENV_PATH$CONDA_PREFIX
local active_conda_env=$(where conda | grep -o -P '(?<=envs/)[\w-]+(?=/bin)') if ! [ -z "$_path" ]; then
fi # config - can be overwritten in users' zshrc file.
if [[ -n $active_conda_env ]]; then set_default POWERLEVEL9K_ANACONDA_LEFT_DELIMITER "("
"$1_prompt_segment" "$0" "$2" "green" "black" "($active_conda_env)" "" set_default POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER ")"
"$1_prompt_segment" "$0" "$2" "$3" "$4" "$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" 'PYTHON_ICON'
fi fi
} }

Loading…
Cancel
Save