home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

j (937B)


      1 local root=~/src/
      2 local res results args
      3 
      4 while 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}"
     10 done
     11 (( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
     12 
     13 local fnd=$1
     14 type -f zshz 2>/dev/null >/dev/null || opt_n=true
     15 
     16 if [[ -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}"
     27 fi
     28 
     29 res=$(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} ; }