fix: rbenv plugin - gemset.
Robby Russell authored on 26/12/2011 at 18:33:171 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,44 @@ |
0 |
+FOUND_RBENV=0 |
|
1 |
+for rbenvdir in "$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" ; do |
|
2 |
+ if [ -d $rbenvdir/bin -a $FOUND_RBENV -eq 0 ] ; then |
|
3 |
+ FOUND_RBENV=1 |
|
4 |
+ export RBENV_ROOT=$rbenvdir |
|
5 |
+ export PATH=${rbenvdir}/bin:$PATH |
|
6 |
+ eval "$(rbenv init -)" |
|
7 |
+ |
|
8 |
+ alias rubies="rbenv versions" |
|
9 |
+ alias gemsets="rbenv gemset list" |
|
10 |
+ |
|
11 |
+ function current_ruby() { |
|
12 |
+ echo "$(rbenv version-name)" |
|
13 |
+ } |
|
14 |
+ |
|
15 |
+ function current_gemset() { |
|
16 |
+ echo "$(rbenv gemset active 2&>/dev/null | sed -e ":a" -e '$ s/\n/+/gp;N;b a' | head -n1)" |
|
17 |
+ } |
|
18 |
+ |
|
19 |
+ function gems { |
|
20 |
+ local rbenv_path=$(rbenv prefix) |
|
21 |
+ gem list $@ | sed \ |
|
22 |
+ -Ee "s/\([0-9\.]+( .+)?\)/$fg[blue]&$reset_color/g" \ |
|
23 |
+ -Ee "s|$(echo $rbenv_path)|$fg[magenta]\$rbenv_path$reset_color|g" \ |
|
24 |
+ -Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \ |
|
25 |
+ -Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g" |
|
26 |
+ } |
|
27 |
+ |
|
28 |
+ function rbenv_prompt_info() { |
|
29 |
+ if [[ -n $(current_gemset) ]] ; then |
|
30 |
+ echo "$(current_ruby)@$(current_gemset)" |
|
31 |
+ else |
|
32 |
+ echo "$(current_ruby)" |
|
33 |
+ fi |
|
34 |
+ } |
|
35 |
+ fi |
|
36 |
+done |
|
37 |
+unset rbenvdir |
|
38 |
+ |
|
39 |
+if [ $FOUND_RBENV -eq 0 ] ; then |
|
40 |
+ alias rubies='ruby -v' |
|
41 |
+ function gemsets() { echo 'not supported' } |
|
42 |
+ function rbenv_prompt_info() { echo "system: $(ruby -v | cut -f-2 -d ' ')" } |
|
43 |
+fi |