f3bcf864b2e1255788c795fc4774260c686b2de6
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Merge pull request #1209 from lwe/rbfu-plugin
provide plugin for rbfu (yet ruby version switcher)
Diff
1diff --git a/plugins/rbfu/rbfu.plugin.zsh b/plugins/rbfu/rbfu.plugin.zsh
2new file mode 100644
3index 0000000000000000000000000000000000000000..0084852054d3c78856b24187a2e485d02b5e04c8
4--- /dev/null
5+++ b/plugins/rbfu/rbfu.plugin.zsh
6@@ -0,0 +1,42 @@
7+# Enables rbfu with --auto option, if available.
8+#
9+# Also provides a command to list all installed/available
10+# rubies. To ensure compatibility with themes, creates the
11+# rvm_prompt_info function to return the $RBFU_RUBY_VERSION
12+# version.
13+
14+command -v rbfu &>/dev/null
15+
16+if [[ $? -eq 0 ]]; then
17+ eval "$(rbfu --init --auto)"
18+
19+ # Internal: Print ruby version details, if it's currently
20+ # active etc.
21+ function _rbfu_rubies_print() {
22+ local rb rb_out
23+ rb=$(basename $1)
24+ rb_out="$rb"
25+ [[ -h $1 ]] && rb_out="$rb_out${fg[green]}@${reset_color}"
26+ [[ "x$rb" == "x$2" ]] && rb_out="${fg[red]}$rb_out ${fg[red]}*${reset_color}"
27+ echo $rb_out
28+ }
29+
30+ # Public: Provide a list with all available rubies, this basically depends
31+ # on `ls -1` and .rfbu/rubies. Highlights the currently active ruby version
32+ # and aliases.
33+ function rbfu-rubies() {
34+ local rbfu_dir active_rb
35+ rbfu_dir=$RBFU_RUBIES
36+ active_rb=$RBFU_RUBY_VERSION
37+ [[ -z "$rbfu_dir" ]] && rbfu_dir="${HOME}/.rbfu/rubies"
38+ [[ -z "$active_rb" ]] && active_rb="system"
39+ _rbfu_rubies_print "${rbfu_dir}/system" $active_rb
40+ for rb in $(ls -1 $rbfu_dir); do
41+ _rbfu_rubies_print "${rbfu_dir}/${rb}" $active_rb
42+ done
43+ }
44+
45+ # Public: Create rvm_prompt_info command for themes compatibility, unless
46+ # it has already been defined.
47+ [ ! -x rvm_prompt_info ] && function rvm_prompt_info() { echo "${RBFU_RUBY_VERSION:=system}" }
48+fi