Last active
July 3, 2018 19:33
-
-
Save frebib/2b4ba154a9d62b31b1edcb50477e7f01 to your computer and use it in GitHub Desktop.
Pretty-pwd, from the fish shell, in POSIX sh
This file contains hidden or 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 | |
set -e -o pipefail | |
# This sed expression is POSIX compliant and provides 99.9% the same functionality as the previous revision | |
# The only caveat is with paths that contain % (percent) characters. This can be changed for # or something else if desired | |
pwd | sed -E 's|^'$HOME'|~|;s|(.*)/|\1%|;s|((^\|/)\.?[^/%]{1})[^/%]*|\1|g;s|(.*)%|\1/|' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment