Created
June 20, 2017 21:54
-
-
Save mythril/67c491303175a5ec751dbd8aac6c8f70 to your computer and use it in GitHub Desktop.
nice bash prompt
This file contains 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 showPath() { | |
path=$(dirname `pwd`); | |
wd=$(basename `pwd`); | |
homedir=$(echo ~); | |
escaped=$(printf '%q' $homedir); | |
out=$(echo $path|sed -e 's%^'${escaped}'%~%'); | |
echo -n $out; | |
echo -n "/"; | |
tput setaf 2; | |
tput bold; | |
echo -n $wd; | |
tput sgr 0; | |
} | |
function showBranch() { | |
tput setab 7; | |
tput setaf 0; | |
tput bold; | |
git rev-parse --abbrev-ref HEAD 2>/dev/null |tr -d "\n"; | |
tput sgr 0; | |
} | |
if [ "$(id -u)" != "0" ]; then | |
export PS1="\n[\$(tput setab 4;tput setaf 7;tput bold)\u\$(tput sgr0)@\$(tput setaf 3;tput bold)\H\$(tput sgr0):\$(showPath) {\$(showBranch)}]\n$ " | |
else | |
export PS1="\n[\$(tput setab 1;tput setaf 7;tput bold)\u\$(tput sgr0)@\$(tput setaf 3;tput bold)\H\$(tput sgr0):\$(showPath) {\$(showBranch)}]\n$ " | |
fi | |
export PATH=/home/dev/.composer/vendor/bin:$PATH:$HOME/bin:/usr/local/go/bin:$HOME/php/vendor/bin:/opt/node/bin | |
export GOPATH=$HOME/go | |
umask 0002 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment