main
 1local root=~/src/
 2local res results args
 3
 4while getopts "np" opt; do
 5  if [[ $opt = "?" ]]; then
 6    print -r -- "$myname: unrecognized option: -$OPTARG" >&2
 7    return 1
 8  fi
 9  eval "opt_$opt=\${OPTARG:--\$opt}"
10done
11(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
12
13local fnd=$1
14type -f zshz 2>/dev/null >/dev/null || opt_n=true
15
16if [[ -n ${fnd} ]];then
17
18    [[ -z ${opt_n} ]] && {
19        local zz=$(zshz -e ${fnd})
20        [[ -n ${zz} ]] && { echo "ZSHZ: ${zz}"; [[ -z ${opt_p} ]] && cd ${zz}; return;}
21    }
22
23    local results=($(fd -d 3 -t d . ${root}|egrep -i "${fnd}"))
24    [[ ${#results} == 1 ]] && { echo ${results}; [[ -z ${opt_p} ]] && cd ${results} ; return;}
25    [[ ${#results} == 0 ]] && { echo "No results found for ${fnd}"; return 1;}
26    args="-q ${fnd}"
27fi
28
29res=$(fd -d 3 -t d . ${root}|sed "s,${root},,"|fzf --height 50% --border ${args})
30[[ -n ${res} ]] && {echo ${root}${res}; [[ -z ${opt_p} ]]  && cd ${root}${res} ; }