From 8a62fceb7b114d3121cd3d67c03a99e945eadcce Mon Sep 17 00:00:00 2001 From: Lion Krischer Date: Fri, 15 Jul 2016 16:26:37 +0200 Subject: [PATCH 1/7] Much faster conda env detection - no more file I/O needed. --- powerlevel9k.zsh-theme | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index a1d18cb1..57058a70 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -291,13 +291,8 @@ CURRENT_BG='NONE' # Anaconda Environment prompt_anaconda() { - if $(hash ack 2>/dev/null); then - local active_conda_env=$(where conda | ack -o '(?<=envs/)[\w-]+(?=/bin)') - else - local active_conda_env=$(where conda | grep -o -P '(?<=envs/)[\w-]+(?=/bin)') - fi - if [[ -n $active_conda_env ]]; then - "$1_prompt_segment" "$0" "$2" "green" "black" "($active_conda_env)" "" + if ! [ -z ${CONDA_ENV_PATH+x} ]; then + "$1_prompt_segment" "$0" "$2" "green" "black" "($(basename $CONDA_ENV_PATH))" "" fi } From c382c538f0a74a5c551f741ced723ac39fdb3aa2 Mon Sep 17 00:00:00 2001 From: Lion Krischer Date: Fri, 15 Jul 2016 17:02:46 +0200 Subject: [PATCH 2/7] Make the conda prompt fully configurable --- powerlevel9k.zsh-theme | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 57058a70..4aeb68a4 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -292,7 +292,13 @@ CURRENT_BG='NONE' # Anaconda Environment prompt_anaconda() { if ! [ -z ${CONDA_ENV_PATH+x} ]; then - "$1_prompt_segment" "$0" "$2" "green" "black" "($(basename $CONDA_ENV_PATH))" "" + # config - can be overwritten in users' zshrc file. + defined POWERLEVEL9K_ANACONDA_BG_COLOR || POWERLEVEL9K_ANACONDA_BG_COLOR=green + defined POWERLEVEL9K_ANACONDA_FG_COLOR || POWERLEVEL9K_ANACONDA_FG_COLOR=black + defined POWERLEVEL9K_ANACONDA_PREFIX || POWERLEVEL9K_ANACONDA_PREFIX="" + defined POWERLEVEL9K_ANACONDA_LEFT_DELIMITER || POWERLEVEL9K_ANACONDA_LEFT_DELIMITER="(" + defined POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER || POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER=")" + "$1_prompt_segment" "$0" "$2" "$POWERLEVEL9K_ANACONDA_BG_COLOR" "$POWERLEVEL9K_ANACONDA_FG_COLOR" "$POWERLEVEL9K_ANACONDA_PREFIX$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $CONDA_ENV_PATH)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" "" fi } From fb211bc04cce1f3bd46a6d7c6463ef4b24691438 Mon Sep 17 00:00:00 2001 From: Lion Krischer Date: Fri, 15 Jul 2016 17:20:00 +0200 Subject: [PATCH 3/7] Document all the conda prompt changes --- README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d2e40da0..8478fb3a 100644 --- a/README.md +++ b/README.md @@ -140,13 +140,18 @@ The segments that are currently available are: ##### anaconda -This segment shows your active anaconda environment. +This segment shows your active anaconda environment. It relies on the +`CONDA_ENV_PATH` environment variable to be set which happens when you properly +`source activate` an environment. -*Note: This segment relies on a perl-regex with lookbehind. -If `ack` is not available the segment will try to use `grep`. -Recent versions of grep offer a `-P` option to handle such things. -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`.* + +| Variable | Default Value | Description | +|----------|---------------|-------------| +|`POWERLEVEL9K_ANACONDA_BG_COLOR`|"green"|Background color of the segment.| +|`POWERLEVEL9K_ANACONDA_FG_COLOR`|"black"|Foreground color of the segment.| +|`POWERLEVEL9K_ANACONDA_PREFIX`|""|Prefix before the environment name.| +|`POWERLEVEL9K_ANACONDA_LEFT_DELIMITER`|"("|The left delimiter just before the environment name.| +|`POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER`|")"|The right delimiter just after the environment name.| ##### aws From 97e5684e5272429ae40acd4528716f64585be0a5 Mon Sep 17 00:00:00 2001 From: Lion Krischer Date: Tue, 26 Jul 2016 11:39:00 +0200 Subject: [PATCH 4/7] Adapting to newer conda version --- powerlevel9k.zsh-theme | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 4aeb68a4..1f3d1ad6 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -291,14 +291,17 @@ CURRENT_BG='NONE' # Anaconda Environment prompt_anaconda() { - if ! [ -z ${CONDA_ENV_PATH+x} ]; then + # Depending on the conda version, either might be set. This + # variant works even if both are set. + _path=$CONDA_ENV_PATH$CONDA_PREFIX + if ! [ -z "$_path" ]; then # config - can be overwritten in users' zshrc file. defined POWERLEVEL9K_ANACONDA_BG_COLOR || POWERLEVEL9K_ANACONDA_BG_COLOR=green defined POWERLEVEL9K_ANACONDA_FG_COLOR || POWERLEVEL9K_ANACONDA_FG_COLOR=black defined POWERLEVEL9K_ANACONDA_PREFIX || POWERLEVEL9K_ANACONDA_PREFIX="" defined POWERLEVEL9K_ANACONDA_LEFT_DELIMITER || POWERLEVEL9K_ANACONDA_LEFT_DELIMITER="(" defined POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER || POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER=")" - "$1_prompt_segment" "$0" "$2" "$POWERLEVEL9K_ANACONDA_BG_COLOR" "$POWERLEVEL9K_ANACONDA_FG_COLOR" "$POWERLEVEL9K_ANACONDA_PREFIX$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $CONDA_ENV_PATH)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" "" + "$1_prompt_segment" "$0" "$2" "$POWERLEVEL9K_ANACONDA_BG_COLOR" "$POWERLEVEL9K_ANACONDA_FG_COLOR" "$POWERLEVEL9K_ANACONDA_PREFIX$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" "" fi } From 50b978ddc8a8fd6f6372a66043526147eaba5046 Mon Sep 17 00:00:00 2001 From: Lion Krischer Date: Wed, 31 Aug 2016 00:21:01 +0200 Subject: [PATCH 5/7] Using default color setters --- README.md | 4 ++-- powerlevel9k.zsh-theme | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8478fb3a..f1d1bbeb 100644 --- a/README.md +++ b/README.md @@ -147,8 +147,8 @@ This segment shows your active anaconda environment. It relies on the | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_ANACONDA_BG_COLOR`|"green"|Background color of the segment.| -|`POWERLEVEL9K_ANACONDA_FG_COLOR`|"black"|Foreground color of the segment.| +|`POWERLEVEL9K_ANACONDA_BACKGROUND`|"green"|Background color of the segment.| +|`POWERLEVEL9K_ANACONDA_FOREGROUND`|"black"|Foreground color of the segment.| |`POWERLEVEL9K_ANACONDA_PREFIX`|""|Prefix before the environment name.| |`POWERLEVEL9K_ANACONDA_LEFT_DELIMITER`|"("|The left delimiter just before the environment name.| |`POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER`|")"|The right delimiter just after the environment name.| diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 1f3d1ad6..93927f72 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -296,12 +296,10 @@ prompt_anaconda() { _path=$CONDA_ENV_PATH$CONDA_PREFIX if ! [ -z "$_path" ]; then # config - can be overwritten in users' zshrc file. - defined POWERLEVEL9K_ANACONDA_BG_COLOR || POWERLEVEL9K_ANACONDA_BG_COLOR=green - defined POWERLEVEL9K_ANACONDA_FG_COLOR || POWERLEVEL9K_ANACONDA_FG_COLOR=black defined POWERLEVEL9K_ANACONDA_PREFIX || POWERLEVEL9K_ANACONDA_PREFIX="" defined POWERLEVEL9K_ANACONDA_LEFT_DELIMITER || POWERLEVEL9K_ANACONDA_LEFT_DELIMITER="(" defined POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER || POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER=")" - "$1_prompt_segment" "$0" "$2" "$POWERLEVEL9K_ANACONDA_BG_COLOR" "$POWERLEVEL9K_ANACONDA_FG_COLOR" "$POWERLEVEL9K_ANACONDA_PREFIX$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" "" + "$1_prompt_segment" "$0" "$2" "$3" "$4" "$POWERLEVEL9K_ANACONDA_PREFIX$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" "" fi } From 35beead4308a164797fe4bd9026d860628064888 Mon Sep 17 00:00:00 2001 From: Lion Krischer Date: Wed, 31 Aug 2016 00:23:38 +0200 Subject: [PATCH 6/7] Using set_default function --- powerlevel9k.zsh-theme | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 93927f72..c956cac8 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -296,9 +296,9 @@ prompt_anaconda() { _path=$CONDA_ENV_PATH$CONDA_PREFIX if ! [ -z "$_path" ]; then # config - can be overwritten in users' zshrc file. - defined POWERLEVEL9K_ANACONDA_PREFIX || POWERLEVEL9K_ANACONDA_PREFIX="" - defined POWERLEVEL9K_ANACONDA_LEFT_DELIMITER || POWERLEVEL9K_ANACONDA_LEFT_DELIMITER="(" - defined POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER || POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER=")" + set_default POWERLEVEL9K_ANACONDA_PREFIX "" + set_default POWERLEVEL9K_ANACONDA_LEFT_DELIMITER "(" + set_default POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER ")" "$1_prompt_segment" "$0" "$2" "$3" "$4" "$POWERLEVEL9K_ANACONDA_PREFIX$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" "" fi } From 9bc55ab175f2bf48e6673327df7e814de35f9d1e Mon Sep 17 00:00:00 2001 From: Lion Krischer Date: Wed, 31 Aug 2016 00:31:33 +0200 Subject: [PATCH 7/7] Using default way of setting icons and updating doc --- README.md | 15 +++++++++------ powerlevel9k.zsh-theme | 3 +-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f1d1bbeb..2d031706 100644 --- a/README.md +++ b/README.md @@ -140,19 +140,22 @@ The segments that are currently available are: ##### anaconda -This segment shows your active anaconda environment. It relies on the -`CONDA_ENV_PATH` environment variable to be set which happens when you properly -`source activate` an 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. +Special configuration variables: | Variable | Default Value | Description | |----------|---------------|-------------| -|`POWERLEVEL9K_ANACONDA_BACKGROUND`|"green"|Background color of the segment.| -|`POWERLEVEL9K_ANACONDA_FOREGROUND`|"black"|Foreground color of the segment.| -|`POWERLEVEL9K_ANACONDA_PREFIX`|""|Prefix before the environment name.| |`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 If you would like to display the [current AWS diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c956cac8..b9af0cfa 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -296,10 +296,9 @@ prompt_anaconda() { _path=$CONDA_ENV_PATH$CONDA_PREFIX if ! [ -z "$_path" ]; then # config - can be overwritten in users' zshrc file. - set_default POWERLEVEL9K_ANACONDA_PREFIX "" set_default POWERLEVEL9K_ANACONDA_LEFT_DELIMITER "(" set_default POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER ")" - "$1_prompt_segment" "$0" "$2" "$3" "$4" "$POWERLEVEL9K_ANACONDA_PREFIX$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" "" + "$1_prompt_segment" "$0" "$2" "$3" "$4" "$POWERLEVEL9K_ANACONDA_LEFT_DELIMITER$(basename $_path)$POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER" 'PYTHON_ICON' fi }