diff --git a/diralias b/diralias new file mode 100644 index 0000000..5d35afb --- /dev/null +++ b/diralias @@ -0,0 +1,32 @@ +function diralias +{ + typeset -i i=0 + + case $# in + 0) + while (( i < ${#DIRALIASNAM[@]} )) + do + printf "%s\t%s\n" ${DIRALIASNAM[i]} "${DIRALIASVAL[i]}" + let i++ + done + ;; + 1) + while [[ $i -lt ${#DIRALIASNAM[@]} && $1 != ${DIRALIASNAM[i]} ]] + do + let i++ + done + (( i == ${#DIRALIASNAM[@]} )) && print $1 || print ${DIRALIASVAL[i]} + ;; + 2) + while [[ $i -lt ${#DIRALIASNAM[@]} && $1 != ${DIRALIASNAM[i]} ]] + do + let i++ + done + DIRALIASNAM[i]=$1 + DIRALIASVAL[i]="$2" + ;; + *) + exit 64 + ;; + esac +} diff --git a/j b/j new file mode 100644 index 0000000..69086a4 --- /dev/null +++ b/j @@ -0,0 +1,13 @@ +function j +{ + typeset da + da=$(diralias $1) + if print $da | grep '^!' >/dev/null + then + if ! da=$(eval $(print "$da" | sed 's/^!//') 2>/dev/null) + then + return 65 + fi + fi + 'cd' "$da" +}