Skip to content

Commit 3a6af27

Browse files
committed
[zsh] emulate -L zsh to avoid issues with incompatible options
Close #858
1 parent c89ac34 commit 3a6af27

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

shell/completion.zsh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ __fzf_generic_path_completion() {
4646
tail=$6
4747
fzf="$(__fzfcmd_complete)"
4848

49-
setopt localoptions nonomatch
49+
setopt nonomatch
5050
dir="$base"
5151
while [ 1 ]; do
5252
if [[ -z "$dir" || -d ${~dir} ]]; then
@@ -142,8 +142,8 @@ _fzf_complete_unalias() {
142142
}
143143
144144
fzf-completion() {
145+
emulate -L zsh
145146
local tokens cmd prefix trigger tail fzf matches lbuf d_cmds
146-
setopt localoptions noshwordsplit noksh_arrays
147147
148148
# http://zsh.sourceforge.net/FAQ/zshfaq03.html
149149
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags

shell/key-bindings.zsh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ __fzfcmd() {
2727
}
2828

2929
fzf-file-widget() {
30+
emulate -L zsh
3031
LBUFFER="${LBUFFER}$(__fsel)"
3132
local ret=$?
3233
zle redisplay
@@ -38,9 +39,10 @@ bindkey '^T' fzf-file-widget
3839

3940
# ALT-C - cd into the selected directory
4041
fzf-cd-widget() {
42+
emulate -L zsh
43+
setopt pipefail 2> /dev/null
4144
local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
4245
-o -type d -print 2> /dev/null | cut -b3-"}"
43-
setopt localoptions pipefail 2> /dev/null
4446
local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)"
4547
if [[ -z "$dir" ]]; then
4648
zle redisplay
@@ -57,8 +59,9 @@ bindkey '\ec' fzf-cd-widget
5759

5860
# CTRL-R - Paste the selected command from history into the command line
5961
fzf-history-widget() {
62+
emulate -L zsh
63+
setopt pipefail 2> /dev/null
6064
local selected num
61-
setopt localoptions noglobsubst pipefail 2> /dev/null
6265
selected=( $(fc -l 1 |
6366
FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS +s --tac -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS --query=${(q)LBUFFER} +m" $(__fzfcmd)) )
6467
local ret=$?

0 commit comments

Comments
 (0)