Last active
February 5, 2016 15:14
-
-
Save robhurring/d9f26da9db56f3f84912 to your computer and use it in GitHub Desktop.
shortenpath for zsh/bash
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
/u/local: pwd b3bb610 | |
/usr/local | |
~/P/proccli: pwd master da99d97 2↓ ✽ | |
/Users/rob/Projects/proccli |
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
# vim-like shortenpath() function | |
# modified from http://stackoverflow.com/questions/25945993/how-to-get-a-vim-tab-like-short-path-in-bash-script | |
shortenpath() { | |
print -n "${1}" | sed -e "s|${HOME}|~|" -e 's:\(/*\)\([^\.]\)[^/]*/:\1\2/:g' | |
} |
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
shortenpath "$(pwd)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment