1
0
Fork 0
mirror of synced 2024-11-09 18:18:56 -05:00
zimfw/modules/fasd/init.zsh
Matt Hamilton 03f15c4495 [fasd] add initial fasd support
[zlogin] zcompare fasd and all functions

[fasd] trim non-zsh options

[fasd] merge PR #75 from clvv/fasd

[fasd] partial merge PR #77 from clvv/fasd

This closes #24
2016-03-27 18:45:05 -04:00

56 lines
1.7 KiB
Bash

fasd --init env
alias a='fasd -a'
alias s='fasd -si'
alias sd='fasd -sid'
alias sf='fasd -sif'
alias d='fasd -d'
alias f='fasd -f'
alias z='fasd_cd -d'
alias zz='fasd_cd -d -i'
# add zsh hook
autoload -Uz add-zsh-hook
add-zsh-hook preexec _fasd_preexec
# enable command mode completion
compctl -U -K _fasd_zsh_cmd_complete -V fasd -x 'C[-1,-*e],s[-]n[1,e]' -c - \
'c[-1,-A][-1,-D]' -f -- fasd fasd_cd
(( $+functions[compdef] )) && {
# zsh word mode completion
_fasd_zsh_word_complete() {
}
_fasd_zsh_word_complete_f() { _fasd_zsh_word_complete f ; }
_fasd_zsh_word_complete_d() { _fasd_zsh_word_complete d ; }
_fasd_zsh_word_complete_trigger() {
local _fasd_cur="${words[CURRENT]}"
eval $(fasd --word-complete-trigger _fasd_zsh_word_complete $_fasd_cur)
}
# define zle widgets
zle -C fasd-complete complete-word _generic
zstyle ':completion:fasd-complete:*' completer _fasd_zsh_word_complete
zstyle ':completion:fasd-complete:*' menu-select
zle -C fasd-complete-f complete-word _generic
zstyle ':completion:fasd-complete-f:*' completer _fasd_zsh_word_complete_f
zstyle ':completion:fasd-complete-f:*' menu-select
zle -C fasd-complete-d complete-word _generic
zstyle ':completion:fasd-complete-d:*' completer _fasd_zsh_word_complete_d
zstyle ':completion:fasd-complete-d:*' menu-select
}
(( $+functions[compdef] )) && {
# enable word mode completion
orig_comp="$(zstyle -L ':completion:\*' completer 2>> "/dev/null")"
if [ "$orig_comp" ]; then
case $orig_comp in
*_fasd_zsh_word_complete_trigger*);;
*) eval "$orig_comp _fasd_zsh_word_complete_trigger";;
esac
else
zstyle ':completion:*' completer _complete _fasd_zsh_word_complete_trigger
fi
unset orig_comp
}