Given that the shell understands tilde
(sigil) notation:
Code:
$ cd ~
$ pwd
/home/username
$
Is there any utility which will condense an absolute pathname down to using a tilde if possible? ie:
/home/username/dev would be reduced down to
~/dev?
I know I can do this through
sed(1):
Code:
#!/bin/sh
s=$(echo "$PWD" | sed "s!^$HOME\(.*$\)!~\1!")
...but is there some utility which already accomplishes the same functionality?
Thanks.