Created
June 8, 2012 02:24
-
-
Save daveyeu/2893119 to your computer and use it in GitHub Desktop.
Short PWD
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
# | |
# Spit out a shortened working directory | |
# | |
# I tried out the fish shell (http://ridiculousfish.com/shell/) recently | |
# after it showed up on Hacker News, and the part I really liked was the | |
# shortened working directory on the prompt: | |
# | |
# dave@lew ~/w/g/transport> | |
# | |
# Here's a first cut at making it work for bash. | |
# | |
function short_pwd { | |
echo $PWD | sed "s:${HOME}:~:" | sed "s:/\(.\)[^/]*:/\1:g" | sed "s:/[^/]*$:/$(basename $PWD):" | |
} | |
PS1="\u@\h:\$(short_pwd)\$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment