Last active
September 3, 2020 10:40
-
-
Save amolpednekar/6eacca7db9e8223fddfbe4f73ca1eb05 to your computer and use it in GitHub Desktop.
Show limited information in 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
If your linux bash prompt (via putty/mobaxterm) is showing the full path of your directory; which can be irritating, update your bashrc's PS1 variables as below to only show the top and bottom 2 directories when there are more than 3 | |
HOST='\[\033[02;36m\]\h'; HOST=' '$HOST | |
TIME='\[\033[01;31m\]\t \[\033[01;32m\]' | |
LOCATION=' \[\033[01;34m\]`pwd | sed "s#\(/[^/]\{1,\}/\).*\(/[^/]\{1,\}/[^/]\{1,\}\)/\{0,1\}#\1_\2#g"`' | |
BRANCH=' \[\033[00;33m\]$(git_branch)\[\033[00m\]\n\$ ' | |
PS1=$TIME$USER$HOST$LOCATION$BRANCH | |
git_branch () { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' | |
} | |
git_branch is a function which shows current git branch (similar to git bash) | |
Result:/home/_/amol_pednekar/workspace | |
Actual location: /home/persistent.co.in/amol_pednekar/workspace/fabric/2.2/fabric-samples |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment