Skip to content

Instantly share code, notes, and snippets.

@daveyeu
Created June 8, 2012 02:24
Show Gist options
  • Save daveyeu/2893119 to your computer and use it in GitHub Desktop.
Save daveyeu/2893119 to your computer and use it in GitHub Desktop.
Short PWD
#
# 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