Created
January 11, 2018 07:41
-
-
Save nyrahul/919cd69d2ccece93e24ce18742dc77c3 to your computer and use it in GitHub Desktop.
Set netns name and git branch name in bash-PS1
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
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
netns_name() { | |
str=`ip netns identify $$` | |
[[ "$str" != "" ]] && echo "\033[1;35m[$str]\033[0m " && return | |
} | |
export PS1="$(netns_name)\u@\h:\[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\]\$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment