functions/xhashd
changeset 22 f84d194b7d99
equal deleted inserted replaced
21:77f885aba914 22:f84d194b7d99
       
     1 
       
     2 ### xhashd(): check for directory, then create hash -d
       
     3 # Copied and slightly modified from Franck Terbeck zsh configuration.
       
     4 # https://dev.0x50.de/projects/ftzsh/repository
       
     5 
       
     6 local key val com
       
     7 if (( ${#argv} == 0 )) ; then
       
     8     printf 'xhashd(): Missing argument.\n'
       
     9     return 1
       
    10 fi
       
    11 if (( ${#argv} > 1 )) ; then
       
    12     printf 'xhashd(): Too many arguments %s\n' "${#argv}"
       
    13     return 1
       
    14 fi
       
    15 
       
    16 key="${1%%\=*}" ;  val="${1#*\=}"
       
    17 val=${val/#\~\//$HOME/}
       
    18 [[ -d ${val} ]] && hash -d -- "${key}=${val}"
       
    19 return 0