-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
75 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
fzf-completion() { | ||
local tokens cmd prefix trigger tail matches lbuf d_cmds | ||
setopt localoptions noshwordsplit noksh_arrays noposixbuiltins | ||
|
||
# http://zsh.sourceforge.net/FAQ/zshfaq03.html | ||
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags | ||
tokens=(${(z)LBUFFER}) | ||
if [ ${#tokens} -lt 1 ]; then | ||
zle ${fzf_default_completion:-expand-or-complete} | ||
return | ||
fi | ||
|
||
cmd=$(__fzf_extract_command "$LBUFFER") | ||
|
||
# Explicitly allow for empty trigger. | ||
trigger=${FZF_COMPLETION_TRIGGER-'**'} | ||
[ -z "$trigger" -a ${LBUFFER[-1]} = ' ' ] && tokens+=("") | ||
|
||
# When the trigger starts with ';', it becomes a separate token | ||
if [[ ${LBUFFER} = *"${tokens[-2]}${tokens[-1]}" ]]; then | ||
tokens[-2]="${tokens[-2]}${tokens[-1]}" | ||
tokens=(${tokens[0,-2]}) | ||
fi | ||
|
||
tail=${LBUFFER:$(( ${#LBUFFER} - ${#trigger} ))} | ||
# Kill completion (do not require trigger sequence) | ||
if [ $cmd = kill -a ${LBUFFER[-1]} = ' ' ]; then | ||
matches=$(command ps -ef | sed 1d | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-50%} --min-height 15 --reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS --preview 'echo {}' --preview-window down:3:wrap" __fzf_comprun "$cmd" -m | awk '{print $2}' | tr '\n' ' ') | ||
if [ -n "$matches" ]; then | ||
LBUFFER="$LBUFFER$matches" | ||
fi | ||
zle reset-prompt | ||
# Trigger sequence given | ||
elif [ ${#tokens} -gt 1 -a "$tail" = "$trigger" ]; then | ||
d_cmds=(${=FZF_COMPLETION_DIR_COMMANDS:-cd pushd rmdir}) | ||
|
||
[ -z "$trigger" ] && prefix=${tokens[-1]} || prefix=${tokens[-1]:0:-${#trigger}} | ||
[ -z "${tokens[-1]}" ] && lbuf=$LBUFFER || lbuf=${LBUFFER:0:-${#tokens[-1]}} | ||
|
||
if eval "type _fzf_complete_${cmd} > /dev/null"; then | ||
prefix="$prefix" eval _fzf_complete_${cmd} ${(q)lbuf} | ||
elif [ ${d_cmds[(i)$cmd]} -le ${#d_cmds} ]; then | ||
_fzf_dir_completion "$prefix" "$lbuf" | ||
else | ||
_fzf_path_completion "$prefix" "$lbuf" | ||
fi | ||
# Fall back to default completion | ||
elif eval "type _fzf_complete_${cmd} > /dev/null"; then | ||
prefix="$prefix" eval _fzf_complete_${cmd} ${(q)lbuf} | ||
else | ||
zle ${fzf_default_completion:-expand-or-complete} | ||
fi | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
_fzf_complete_batrak() { | ||
cmd="${BUFFER}" | ||
eval set -- $cmd | ||
zparseopts -E -D -- \ | ||
-l=o_list | ||
echo "o_list=$o_list" >> /tmp/x | ||
} |