-
-
Save chmouel/e616d9bf0896ff61d8681d693b9e1715 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
j () { | |
local root=~/GIT/go/src/github.com/ | |
local res results args | |
while getopts "np" opt | |
do | |
if [[ $opt = "?" ]] | |
then | |
print -r -- "$myname: unrecognized option: -$OPTARG" >&2 | |
return 1 | |
fi | |
eval "opt_$opt=\${OPTARG:--\$opt}" | |
done | |
(( OPTIND > 1 )) && shift $(( OPTIND - 1 )) | |
local fnd=$1 | |
type -f zshz 2> /dev/null > /dev/null || opt_n=true | |
if [[ -n ${fnd} ]] | |
then | |
[[ -z ${opt_n} ]] && { | |
local zz=$(zshz -e ${fnd}) | |
[[ -n ${zz} ]] && { | |
echo "ZSHZ: ${zz}" | |
[[ -z ${opt_p} ]] && cd ${zz} | |
return | |
} | |
} | |
local results=($(fd -d 2 -t d . ${root}|gegrep -i "${fnd}")) | |
[[ ${#results} == 1 ]] && { | |
echo ${results} | |
[[ -z ${opt_p} ]] && cd ${results} | |
return | |
} | |
[[ ${#results} == 0 ]] && { | |
echo "No results found for ${fnd}" | |
return 1 | |
} | |
args="-q ${fnd}" | |
fi | |
res=$(fd -d 2 -t d . ${root}|sed "s,${root},,"|fzf --height 50% --border ${args}) | |
[[ -n ${res} ]] && { | |
echo ${root}${res} | |
[[ -z ${opt_p} ]] && cd ${root}${res} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment