[zsh-completion] Completion for unknown commands
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Junegunn Choi · committed by Junegunn Choi · parent f4a595e · Browse files · 2 files·+4 added−22 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+4 added−22 removed
- tests:+1 added−1 removed
- other:+3 added−21 removed
Provenance
- Commit
dc64568- Tree
e98a6de- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
f4a595e
2 files changed+4 added−22 removed
modified:shell/completion.zsh+3 added-21 removed
45 unmodified lines464748495051525354555051525338 unmodified lines92939495102969798991007 unmodified lines10810911011111811912012112212312412512612711211311411511613313413513611711811912012112212312412512612712812913014 unmodified lines45 unmodified lines "-name .git -prune -o -name .svn -prune -o -type d -print -o -type f -print -o -type l -print" \ "-m" "" " "}
_fzf_file_completion() { _fzf_path_completion "$1" "$2" \ "-name .git -prune -o -name .svn -prune -o -type f -print -o -type l -print" \ "-m" "" " "}
_fzf_dir_completion() { _fzf_path_completion "$1" "$2" \ "-name .git -prune -o -name .svn -prune -o -type d -print" \ "" "/" ""38 unmodified linesEOF}
fzf-zsh-completion() { local tokens cmd prefix trigger tail fzf matches lbuf d_cmds f_cmds a_cmds local tokens cmd prefix trigger tail fzf matches lbuf d_cmds
# http://zsh.sourceforge.net/FAQ/zshfaq03.html tokens=(${=LBUFFER}) if [ ${#tokens} -lt 1 ]; then7 unmodified lines # Trigger sequence given tail=${LBUFFER:$(( ${#LBUFFER} - ${#trigger} ))} if [ ${#tokens} -gt 1 -a $tail = $trigger ]; then d_cmds=(cd pushd rmdir) f_cmds=( awk cat diff diff3 emacs ex file ftp g++ gcc gvim head hg java javac ld less more mvim patch perl python ruby sed sftp sort source tail tee uniq vi view vim wc) a_cmds=( basename bunzip2 bzip2 chmod chown curl cp dirname du find git grep gunzip gzip hg jar ln ls mv open rm rsync scp svn tar unzip zip)
prefix=${tokens[-1]:0:-${#trigger}} lbuf=${LBUFFER:0:-${#tokens[-1]}} if [ ${d_cmds[(i)$cmd]} -le ${#d_cmds} ]; then _fzf_dir_completion "$prefix" $lbuf elif [ ${f_cmds[(i)$cmd]} -le ${#f_cmds} ]; then _fzf_file_completion "$prefix" $lbuf elif [ ${a_cmds[(i)$cmd]} -le ${#a_cmds} ]; then _fzf_all_completion "$prefix" $lbuf elif [ $cmd = telnet ]; then _fzf_telnet_completion "$prefix" $lbuf elif [ $cmd = ssh ]; then _fzf_ssh_completion "$prefix" $lbuf elif [ $cmd = unset -o $cmd = export ]; then _fzf_env_var_completion "$prefix" $lbuf elif [ $cmd = unalias ]; then _fzf_alias_completion "$prefix" $lbuf else _fzf_all_completion "$prefix" $lbuf fi # Kill completion (do not require trigger sequence) elif [ $cmd = kill -a ${LBUFFER[-1]} = ' ' ]; then [ ${FZF_TMUX:-1} -eq 1 ] && fzf="fzf-tmux -d ${FZF_TMUX_HEIGHT:-40%}" || fzf="fzf"14 unmodified linesmodified:test/test_go.rb+1 added-1 removed
124 unmodified lines125 126 def prepare127 tries = 0128 begin129- self.send_keys 'C-u', 'hello'129+ self.send_keys 'C-u', 'hello', 'Right'130 self.until { |lines| lines[-1].end_with?('hello') }131 rescue Exception132 (tries += 1) < 5 ? retry : raise133 end546 unmodified lines