-
-
Save supairish/b5b051cc31fe6a21d08add59c3af5cf0 to your computer and use it in GitHub Desktop.
Bash prompt with rvm, nvm, virtualenv and git integration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function __git_dirty { | |
git diff --quiet HEAD &>/dev/null | |
[ $? == 1 ] && echo " ↺ " | |
} | |
function __git_branch { | |
__git_ps1 "%s" | |
} | |
function __my_rvm_ruby_version { | |
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') | |
[ "$gemset" != "" ] && gemset="@$gemset" | |
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') | |
local full="$version$gemset" | |
[ "$full" != "" ] && echo "rb:$full" | |
} | |
function __virtualenv { | |
local env=$(basename "$VIRTUAL_ENV") | |
[ "$env" != "" ] && echo "py:$env" | |
} | |
function __node { | |
if hash node 2>/dev/null; then | |
local v=$(node -v) | |
fi | |
[ "$v" != "" ] && echo "n:${v:1}" | |
} | |
function __info { | |
local full=( | |
$(__my_rvm_ruby_version) | |
$(__virtualenv) | |
$(__node) | |
$(__git_branch) | |
$(__git_dirty) | |
) | |
full="${full[*]}" | |
[ "$full" != "" ] && echo "[$full]" | |
} | |
PS1="┌─\$(__info)──(\w)\n└─>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment