functions/xhashd
author Mikael Berthe <mikael@lilotux.net>
Sat, 02 Oct 2021 10:49:57 +0200
changeset 52 1f3d221e1770
parent 22 f84d194b7d99
permissions -rw-r--r--
vi mode: Add missing beginning-of-line key bindings Reorder bindings so they are (hopefully) more readable...


### 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