#!/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/|'