diff options
author | Jan Laermann <laermannjan@gmail.com> | 2016-04-19 22:49:57 +0300 |
---|---|---|
committer | Jan Laermann <laermannjan@gmail.com> | 2016-04-19 22:49:57 +0300 |
commit | 391b3327eed75ffd0de4534fdb1ee5227395528e (patch) | |
tree | 2caadb117a25f60430b1e9804abd84a3efa7b04f /powerlevel9k.zsh-theme | |
parent | 511bbcf124552de06a2343ed20bdc97f15a9df2e (diff) |
Added anaconda segment.
The segment relies on a lookaround to determine the currently
active conda environment.
If available ack is preferred, otherwise grep will be used.
Recent versions of grep offer `-P` to support perl-regex.
Older ones (e.g. those shipped on OSX) will fail.
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 8bba6632..d583eaab 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -288,6 +288,18 @@ right_prompt_segment() { # right-left but reads the opposite, this isn't necessary for the other side. 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)" "" + fi +} + # AWS Profile prompt_aws() { local aws_profile="$AWS_DEFAULT_PROFILE" |