Merge pull request #249 from jaermanx9/anaconda-segment

Add anaconda segment.
pull/22/head
Ben Hilburn 9 years ago
commit 08eef3d433

@ -115,6 +115,7 @@ The segments that are currently available are:
* `symfony2_version` - Show the current Symfony2 version, if you are in a Symfony2-Project dir. * `symfony2_version` - Show the current Symfony2 version, if you are in a Symfony2-Project dir.
* **Python Segments:** * **Python Segments:**
* `virtualenv` - Your Python [VirtualEnv](https://virtualenv.pypa.io/en/latest/). * `virtualenv` - Your Python [VirtualEnv](https://virtualenv.pypa.io/en/latest/).
* `anaconda` - Your active [Anaconda](https://www.continuum.io/why-anaconda) environment.
* **Ruby Segments:** * **Ruby Segments:**
* [`chruby`](#chruby) - Ruby environment information using `chruby` (if one is active). * [`chruby`](#chruby) - Ruby environment information using `chruby` (if one is active).
* [`rbenv`](#rbenv) - Ruby environment information using `rbenv` (if one is active). * [`rbenv`](#rbenv) - Ruby environment information using `rbenv` (if one is active).
@ -136,6 +137,16 @@ The segments that are currently available are:
--------------------------------------------------------------------------------- ---------------------------------------------------------------------------------
##### anaconda
This segment shows your active anaconda 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`.*
##### aws ##### aws
If you would like to display the [current AWS If you would like to display the [current AWS

@ -288,6 +288,18 @@ right_prompt_segment() {
# right-left but reads the opposite, this isn't necessary for the other side. # right-left but reads the opposite, this isn't necessary for the other side.
CURRENT_BG='NONE' 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 # AWS Profile
prompt_aws() { prompt_aws() {
local aws_profile="$AWS_DEFAULT_PROFILE" local aws_profile="$AWS_DEFAULT_PROFILE"

Loading…
Cancel
Save