From 001cd7ff742b7c467157152cd532d4b4f00ad69e Mon Sep 17 00:00:00 2001 From: Holger Just Date: Mon, 6 Aug 2018 18:45:36 +0200 Subject: [PATCH] Show Ruby version in PS1 using various possible means --- .bashrc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.bashrc b/.bashrc index f529d29..d7e689e 100644 --- a/.bashrc +++ b/.bashrc @@ -177,7 +177,16 @@ ps1_host='\h' . $HOME/bin/bash_vcs.sh ps1_vcs='$(__prompt_command)' -ps1_ruby=' \[\e[0;34m\]$(rvm-prompt v g)\[\e[00m\]' +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 + # set variable identifying the chroot you work in (used in the prompt below) if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then