# HG changeset patch # User Mikael Berthe # Date 1342805908 -7200 # Node ID f84d194b7d999fae1368ac6cbe468630204d1e94 # Parent 77f885aba9145cd06a1a828f7c1e0038a01bf1b7 Add ft's xhashd function diff -r 77f885aba914 -r f84d194b7d99 functions/xhashd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/functions/xhashd Fri Jul 20 19:38:28 2012 +0200 @@ -0,0 +1,19 @@ + +### xhashd(): check for directory, then create hash -d +# Copied and slightly modified from Franck Terbeck zsh configuration. +# https://dev.0x50.de/projects/ftzsh/repository + +local key val com +if (( ${#argv} == 0 )) ; then + printf 'xhashd(): Missing argument.\n' + return 1 +fi +if (( ${#argv} > 1 )) ; then + printf 'xhashd(): Too many arguments %s\n' "${#argv}" + return 1 +fi + +key="${1%%\=*}" ; val="${1#*\=}" +val=${val/#\~\//$HOME/} +[[ -d ${val} ]] && hash -d -- "${key}=${val}" +return 0 diff -r 77f885aba914 -r f84d194b7d99 zshrc.d/05-autoload.zrc --- a/zshrc.d/05-autoload.zrc Wed Jul 18 21:20:59 2012 +0200 +++ b/zshrc.d/05-autoload.zrc Fri Jul 20 19:38:28 2012 +0200 @@ -7,3 +7,5 @@ # Load standard ANSI color codes in shell parameters autoload -U colors && colors + +autoload -U xhashd