Use site-functions directory for all zsh plugins
This commit is contained in:
33
zsh/_fuzzy_cd
Normal file
33
zsh/_fuzzy_cd
Normal file
@@ -0,0 +1,33 @@
|
||||
#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
|
Reference in New Issue
Block a user