Created
January 2, 2017 19:57
-
-
Save Sporky023/f2dd5fb98cd9d300af122e474e6fd806 to your computer and use it in GitHub Desktop.
bash / PS1 / display two levels of pwd context
This file contains hidden or 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
# thanks: https://muffinresearch.co.uk/showing-last-two-directories-of-pwd-in-bash-prompt/ | |
function PWD { | |
pwd | sed 's/^\/Users\/<YOUR_USERNAME>/~/' | awk -F\/ '{print $(NF-1),$(NF)}' | sed 's/ /\//' | sed 's/~\/~/~/' | |
} | |
export PS1="\u\[\e[m\]:\[\e[36m\]\$(PWD)\[\e[m\] " | |
# backslash before $ tells it to run the function each time; | |
# else it is only run once and won't update as you switch directories |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment