#compdef fcd # Fuzzy cd from anywhere # Dependencies # * fzf # * mlocate # ========== Shortcuts ========== cf() { [[ -z "${*}" ]] && return 1 [[ ! -x /usr/bin/fzf ]] && return 1 dir="$(locate --all --ignore-case --null -- "${@}" | fzf --read0 --select-1 --exit-0)" [[ -z "${dir}" ]] && return 1 if [[ -f "${dir}" ]]; then cd "${dir%/*}" else cd "${dir}" fi } autoload -Uz cf # ========== Completions ========== local arguments arguments=( $argument_list '*:filename:_files' ) _arguments -s $arguments