Skip to content

Instantly share code, notes, and snippets.

@gettalong
Created June 4, 2012 17:46
Show Gist options
  • Save gettalong/2869794 to your computer and use it in GitHub Desktop.
Save gettalong/2869794 to your computer and use it in GitHub Desktop.
Using Ruby in a Bash function to shorten the CWD
function shorten_pwd {
ruby -e "puts Dir.pwd.sub(/^#{ENV['HOME']}/, '~').split('/').map {|l| l.length > 6 ? l[0,3] << '…' << l[-3,3] : l}.join('/')"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment