Skip to content

Instantly share code, notes, and snippets.

@mythril
Created June 20, 2017 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mythril/67c491303175a5ec751dbd8aac6c8f70 to your computer and use it in GitHub Desktop.
Save mythril/67c491303175a5ec751dbd8aac6c8f70 to your computer and use it in GitHub Desktop.
nice bash prompt
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