From 1496f1b5aac6afcc3d472c24dbc958e61b6200f1 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 7 Sep 2008 19:45:21 +0200 Subject: Added rtab --- etc/functions/rtab | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 etc/functions/rtab (limited to 'etc/functions/rtab') 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 +) -- cgit v1.2.3