autoload -U relative
getrel() {
- relative $2:a $1:h
+ # nearly the copy-paste of Functions/Misc/relative
+ local dst=$2:a
+ local src=$1:h:a
+ local -a cur abs
+ cur=(${(s:/:)src})
+ abs=(${(s:/:)dst:h} $dst:t)
+ integer i=1
+ while [[ i -le $#abs && $abs[i] == $cur[i] ]] ; do
+ ((++i > $#cur)) && {
+ REPLY=${(j:/:)abs[i,-1]}
+ return
+ }
+ done
+ src=${(j:/:)cur[i,-1]/*/..}
+ dst=${(j:/:)abs[i,-1]}
+ REPLY=$src${dst:+/$dst}
}
genhtml() {