From b67fde9a334683acb96ba0828159c23a37794697 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Sun, 23 Nov 2014 09:34:59 -0800 Subject: [PATCH] [bobthefish] Add support for rbenv and RVM --- themes/bobthefish/README.md | 2 ++ themes/bobthefish/fish_prompt.fish | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/themes/bobthefish/README.md b/themes/bobthefish/README.md index 07861ee..619d065 100644 --- a/themes/bobthefish/README.md +++ b/themes/bobthefish/README.md @@ -28,6 +28,8 @@ This theme is based loosely on [agnoster][agnoster]. * Background jobs (%) * You currently have superpowers ($) * User@Host (unless you're the default user) + * Current RVM or rbenv (Ruby) version + * Current virtualenv (Python) version * Abbreviated parent directory * Current directory, or Git or Mercurial project name * Current project's repo branch ( master) or detached head (➦ d0dfd9b) diff --git a/themes/bobthefish/fish_prompt.fish b/themes/bobthefish/fish_prompt.fish index 0564576..c555ab7 100644 --- a/themes/bobthefish/fish_prompt.fish +++ b/themes/bobthefish/fish_prompt.fish @@ -46,6 +46,7 @@ set __bobthefish_dk_green 0c4801 set __bobthefish_lt_red C99 set __bobthefish_med_red ce000f set __bobthefish_dk_red 600 +set __bobthefish_ruby_red af0000 set __bobthefish_slate_blue 255e87 set __bobthefish_med_blue 005faf @@ -337,6 +338,22 @@ function __bobthefish_prompt_virtualfish -d "Display activated virtual environme set_color normal end +function __bobthefish_prompt_rubies -d 'Display current Ruby (rvm/rbenv)' + set -l ruby_version + if type rvm-prompt >/dev/null + set ruby_version (rvm-prompt i v g) + else if type rbenv >/dev/null + set ruby_version (rbenv version-name) + # Don't show global ruby version... + [ "$ruby_version" = (rbenv global) ]; and return + end + test -w "$ruby_version"; and return + + __bobthefish_start_segment $__bobthefish_ruby_red $__bobthefish_lt_grey --bold + echo -n -s $ruby_version ' ' + set_color normal +end + # =========================== # Apply theme @@ -345,6 +362,7 @@ end function fish_prompt -d 'bobthefish, a fish theme optimized for awesome' __bobthefish_prompt_status __bobthefish_prompt_user + __bobthefish_prompt_rubies __bobthefish_prompt_virtualfish set -l git_root (__bobthefish_git_project_dir)