Difference between revisions of "Linux shell/Bash prompt PS1, settings and history"
Jump to navigation
Jump to search
(Created page with "This are steps to set up bash prompt showing git branch. This has been tested in Ubuntu 14 LTS Edit vi ~/.bashrc # Uncomment <code>#force_color_prompt=yes</code> # Find <co...") |
|||
Line 22: | Line 22: | ||
= Resources = | = Resources = | ||
*[https://help.ubuntu.com/community/CustomizingBashPrompt CustomizingBashPrompt] Ubuntu wiki | *[https://help.ubuntu.com/community/CustomizingBashPrompt CustomizingBashPrompt] Ubuntu wiki | ||
*[https://github.com/magicmonty/bash-git-prompt/blob/master/README.md Git Bash Prompt repo project] Great informative Git prompt |
Revision as of 12:05, 2 April 2017
This are steps to set up bash prompt showing git branch. This has been tested in Ubuntu 14 LTS
Edit vi ~/.bashrc
- Uncomment
#force_color_prompt=yes
- Find
if [ "$color_prompt" = yes ]; then
statement - then comment out
#PS1=
and add following code in bold
if [ "$color_prompt" = yes ]; then parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' } PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ " #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' #this is default colour prompt else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi
It will similar to
Resources
- CustomizingBashPrompt Ubuntu wiki
- Git Bash Prompt repo project Great informative Git prompt