diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2008-09-07 19:45:21 +0200 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2008-09-07 19:45:21 +0200 |
commit | 1496f1b5aac6afcc3d472c24dbc958e61b6200f1 (patch) | |
tree | 7685bfcd6febd12620006fbab313466f135656f9 /etc/functions/rtab | |
parent | 86421496cb9213cc7e7e12b3c363ff967d3cd0b5 (diff) |
Added rtab
Diffstat (limited to 'etc/functions/rtab')
-rw-r--r-- | etc/functions/rtab | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/etc/functions/rtab b/etc/functions/rtab new file mode 100644 index 0000000..f42af6b --- /dev/null +++ b/etc/functions/rtab @@ -0,0 +1,31 @@ +## vim:ft=zsh +## Needs an absolute directory path as argument +## May not contain ~ or named directories +## CAVEAT: directory-names containing two or more consecutive spaces +## are not yet supported + +typeset -a tree expn +typeset result part dir +typeset -i i +#typeset IFS='/' +tree=(${(s:/:)1}) +( + cd / + for dir in $tree; { + expn=(a b) + part='' + i=0 + # $i -gt 999 <- See CAVEAT - Onterwise we'd have an endless loop here + until [[ (( ${#expn} == 1 )) || $dir = $expn || $i -gt 999 ]] do + (( i++ )) + part+=$dir[$i] + expn=($(echo ${part}*)) +# echo "DEBUG: part=$part" +# echo "DEBUG: expn=${(j:×:)expn}" +# echo "DEBUG: dir=$dir" + done + result+="/$part" + cd $dir + } + echo $result +) |