Last active
January 17, 2018 09:34
-
-
Save tmichel/78c71adbdc1b94a726389ac9d2fe91b6 to your computer and use it in GitHub Desktop.
Abbreviated path: keeping first letter of parent dirs
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
#!/bin/sh | |
# Print $PWD where parent directories are abbreviated to their first letters. | |
# $HOME is replaced with ~. | |
# Based on: https://unix.stackexchange.com/a/26885 | |
sed -e "s:$HOME:~:" -e 's:\([^/]\)[^/]*/:\1/:g' <<<$PWD | |
# PWD=/home/me/foo/bar/baz | |
# => ~/f/b/baz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment