mirror of
https://github.com/lloeki/dotfiles.git
synced 2025-12-06 07:24:39 +01:00
Implement automatic chruby
This commit is contained in:
parent
bd46a6c62a
commit
66ce809703
3 changed files with 27 additions and 4 deletions
1
bash/rc
1
bash/rc
|
|
@ -28,6 +28,7 @@ precmd() {
|
|||
chpwd() {
|
||||
__git_ps1_gitdir
|
||||
_gopath
|
||||
_auto-chruby
|
||||
}
|
||||
chpwd
|
||||
|
||||
|
|
|
|||
29
shell/chruby
29
shell/chruby
|
|
@ -1,7 +1,28 @@
|
|||
if [[ -f /opt/arch/share/chruby/chruby.sh ]]; then
|
||||
source /opt/arch/share/chruby/chruby.sh
|
||||
|
||||
if [[ -f $HOME/.ruby-version ]]; then
|
||||
chruby $(cat $HOME/.ruby-version)
|
||||
fi
|
||||
fi
|
||||
|
||||
_ruby-version() {
|
||||
local check_dir=$PWD
|
||||
local next_check_dir=${check_dir%/*}
|
||||
while [ "$next_check_dir" != "" ]; do
|
||||
if [[ -f "$check_dir/.ruby-version" ]]; then
|
||||
cat "$check_dir/.ruby-version"
|
||||
return
|
||||
fi
|
||||
check_dir="$next_check_dir"
|
||||
next_check_dir=${check_dir%/*}
|
||||
done
|
||||
if [[ -f $HOME/.ruby-version ]]; then
|
||||
cat $HOME/.ruby-version
|
||||
return
|
||||
fi
|
||||
false
|
||||
}
|
||||
|
||||
_auto-chruby() {
|
||||
local ruby_version=$(_ruby-version)
|
||||
if [[ -n "${ruby_version}" ]]; then
|
||||
chruby "${ruby_version}"
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
1
zsh/rc
1
zsh/rc
|
|
@ -35,6 +35,7 @@ preexec() {
|
|||
chpwd() {
|
||||
__git_ps1_gitdir
|
||||
_gopath
|
||||
_auto-chruby
|
||||
}
|
||||
chpwd
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue