mirror of
https://github.com/meineerde/dotfiles.git
synced 2026-02-11 13:15:19 +00:00
Dynamically determine Ruby version for PS1
This commit is contained in:
parent
8d2e9d6057
commit
55778eac5d
27
.bashrc
27
.bashrc
@ -153,16 +153,25 @@ ps1_host='\h'
|
|||||||
|
|
||||||
. $HOME/bin/bash_vcs.sh
|
. $HOME/bin/bash_vcs.sh
|
||||||
ps1_vcs='$(__prompt_command)'
|
ps1_vcs='$(__prompt_command)'
|
||||||
if type rvm-prompt >/dev/null 2>&1; then
|
|
||||||
ps1_ruby=' \[\e[0;34m\]$(rvm-prompt v g)\[\e[00m\]'
|
|
||||||
elif [[ -n "$RUBY_VERSION" ]]; then
|
|
||||||
ps1_ruby=' \[\e[0;34m\]$RUBY_VERSION\[\e[00m\]'
|
|
||||||
elif type ruby >/dev/null 2>&1; then
|
|
||||||
ps1_ruby=' \[\e[0;34m\]$(ruby -e "puts RUBY_VERSION")\[\e[00m\]'
|
|
||||||
else
|
|
||||||
ps1_ruby=''
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
__prompt_ruby_version() {
|
||||||
|
if type rvm-prompt >/dev/null 2>&1; then
|
||||||
|
rvm-prompt v g
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$RUBY_ROOT" ]]; then
|
||||||
|
local ruby_version="$(basename "$RUBY_ROOT")"
|
||||||
|
elif type ruby > /dev/null 2>&1; then
|
||||||
|
local ruby_version="$(ruby -e "puts defined?(RUBY_ENGINE_VERSION) ? \"#{RUBY_ENGINE}-#{RUBY_ENGINE_VERSION}\" : \"ruby-#{RUBY_VERSION}\"")"
|
||||||
|
else
|
||||||
|
local ruby_version=''
|
||||||
|
fi
|
||||||
|
|
||||||
|
ruby_version="${ruby_version#ruby-}"
|
||||||
|
echo "$ruby_version"
|
||||||
|
}
|
||||||
|
ps1_ruby=' \[\e[0;34m\]$(__prompt_ruby_version)\[\e[00m\]'
|
||||||
|
|
||||||
# set variable identifying the chroot you work in (used in the prompt below)
|
# set variable identifying the chroot you work in (used in the prompt below)
|
||||||
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
|
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user