diff options
author | Peter Tillemans <pti@snamellit.com> | 2012-08-08 17:26:54 +0200 |
---|---|---|
committer | Peter Tillemans <pti@snamellit.com> | 2012-08-08 17:26:54 +0200 |
commit | 1a6d11dbae97d5d85129a550ec4aaba070d247e0 (patch) | |
tree | 3417db876f0bfcee95f984cb4b805419f8692b27 /plugins/rbfu/rbfu.plugin.zsh | |
parent | cc98254b62658a988dd8cee0d5e1cb4172b6a064 (diff) | |
parent | d05b2010ffd4cd33ff9402c402051b1caf985d97 (diff) | |
download | zsh-1a6d11dbae97d5d85129a550ec4aaba070d247e0.tar.gz zsh-1a6d11dbae97d5d85129a550ec4aaba070d247e0.tar.bz2 zsh-1a6d11dbae97d5d85129a550ec4aaba070d247e0.zip |
Merge branch 'master' of https://github.com/robbyrussell/oh-my-zsh
Diffstat (limited to 'plugins/rbfu/rbfu.plugin.zsh')
-rw-r--r-- | plugins/rbfu/rbfu.plugin.zsh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/plugins/rbfu/rbfu.plugin.zsh b/plugins/rbfu/rbfu.plugin.zsh new file mode 100644 index 000000000..008485205 --- /dev/null +++ b/plugins/rbfu/rbfu.plugin.zsh @@ -0,0 +1,42 @@ +# Enables rbfu with --auto option, if available. +# +# Also provides a command to list all installed/available +# rubies. To ensure compatibility with themes, creates the +# rvm_prompt_info function to return the $RBFU_RUBY_VERSION +# version. + +command -v rbfu &>/dev/null + +if [[ $? -eq 0 ]]; then + eval "$(rbfu --init --auto)" + + # Internal: Print ruby version details, if it's currently + # active etc. + function _rbfu_rubies_print() { + local rb rb_out + rb=$(basename $1) + rb_out="$rb" + [[ -h $1 ]] && rb_out="$rb_out${fg[green]}@${reset_color}" + [[ "x$rb" == "x$2" ]] && rb_out="${fg[red]}$rb_out ${fg[red]}*${reset_color}" + echo $rb_out + } + + # Public: Provide a list with all available rubies, this basically depends + # on `ls -1` and .rfbu/rubies. Highlights the currently active ruby version + # and aliases. + function rbfu-rubies() { + local rbfu_dir active_rb + rbfu_dir=$RBFU_RUBIES + active_rb=$RBFU_RUBY_VERSION + [[ -z "$rbfu_dir" ]] && rbfu_dir="${HOME}/.rbfu/rubies" + [[ -z "$active_rb" ]] && active_rb="system" + _rbfu_rubies_print "${rbfu_dir}/system" $active_rb + for rb in $(ls -1 $rbfu_dir); do + _rbfu_rubies_print "${rbfu_dir}/${rb}" $active_rb + done + } + + # Public: Create rvm_prompt_info command for themes compatibility, unless + # it has already been defined. + [ ! -x rvm_prompt_info ] && function rvm_prompt_info() { echo "${RBFU_RUBY_VERSION:=system}" } +fi |