Last active
December 21, 2015 05:18
-
-
Save miekg/6255503 to your computer and use it in GitHub Desktop.
Fish like shell path in zsh.
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
# shorten path -> /home/miekg/bla -> /h/m/bla | |
function shorten() { | |
full=$(print -P "$1") | |
a=(${(s:/:)full}) | |
if [[ $#a -eq 0 || $#a -eq 1 ]]; then | |
print $1; return | |
fi | |
last=$a[$#a] | |
a[$#a]= # clear last element | |
for i in $a; do | |
if [[ ${i:0:1} == "~" ]]; then | |
print -n $i | |
continue | |
fi | |
print -n "/"${i:0:1} | |
done | |
print -n "/"$last | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment