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() {
|
chpwd() {
|
||||||
__git_ps1_gitdir
|
__git_ps1_gitdir
|
||||||
_gopath
|
_gopath
|
||||||
|
_auto-chruby
|
||||||
}
|
}
|
||||||
chpwd
|
chpwd
|
||||||
|
|
||||||
|
|
|
||||||
23
shell/chruby
23
shell/chruby
|
|
@ -1,7 +1,28 @@
|
||||||
if [[ -f /opt/arch/share/chruby/chruby.sh ]]; then
|
if [[ -f /opt/arch/share/chruby/chruby.sh ]]; then
|
||||||
source /opt/arch/share/chruby/chruby.sh
|
source /opt/arch/share/chruby/chruby.sh
|
||||||
|
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
|
if [[ -f $HOME/.ruby-version ]]; then
|
||||||
chruby $(cat $HOME/.ruby-version)
|
cat $HOME/.ruby-version
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
_auto-chruby() {
|
||||||
|
local ruby_version=$(_ruby-version)
|
||||||
|
if [[ -n "${ruby_version}" ]]; then
|
||||||
|
chruby "${ruby_version}"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
|
||||||
1
zsh/rc
1
zsh/rc
|
|
@ -35,6 +35,7 @@ preexec() {
|
||||||
chpwd() {
|
chpwd() {
|
||||||
__git_ps1_gitdir
|
__git_ps1_gitdir
|
||||||
_gopath
|
_gopath
|
||||||
|
_auto-chruby
|
||||||
}
|
}
|
||||||
chpwd
|
chpwd
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue