Commit Graph

235 Commits (20230117636c9dfa3ed6f6428c5bc4c51b02f60a)

Author SHA1 Message Date
John Fred Fadrigalan 4603d540c3
[shell] Make bash/zsh completion and bindings work with 'set -u' (#2999)
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2 years ago
Junegunn Choi f931e53890
[fish] Do not use `builtin cd`
`builtin cd` of fish doesn't support `cd -`

Close #2967
2 years ago
knutze b9e6e7926c
[bash] Fix completion of var or alias containing newlines (#2952)
* Fix bash completion var or aliase containing newlines

* Support for various bash declare options

Co-authored-by: knutze <shakte@gmail.com>
2 years ago
Junegunn Choi 6fb41a202a
Add --scheme=[default|path|history] option to choose scoring scheme
Close #2909
Close #2930
2 years ago
Junegunn Choi 6532b3e655
[completion] Remove extra trailing slash on directory completion
Fix #2931
2 years ago
lbesnard a8e7021be2
[completion] ssh: Remove values with '%' (#2548)
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2 years ago
kissge 475469a2e7
[zsh] Make awk regex compatible with both GNU and macOS (#2906) 2 years ago
Bob Matcuk 68cf393644
[bash] Fix 'possible retry loop' problem of bash-completion (#2891)
Close #2474
Close #2583
2 years ago
Junegunn Choi 52594355bf
[shell] 'kill' completion will now require trigger sequence (**)
'kill **<tab>' instead of 'kill <tab>' just like any other completions.

Close #2716
Close #385
2 years ago
Jakub Jirutka 8df872a482
[zsh] Replace perl with awk (#2777)
Unlike awk, which is even defined in POSIX, perl is not pre-installed
on all *nix systems. This awk command is functionally equivalent to
the original perl command.
2 years ago
Jonathan Zacsh c79c306adb
[bash] Fix `fzf-tmux` to have `fzf`'s completion (#2871) 2 years ago
Jan Warchoł 6dcf5c3d7d
[bash] Make complex commands slightly more friendly to work with (#2784)
- extract logical parts to separate variables (e.g. $opts)
- put options in $opts in similar order
- move +/-m into $opts (at the end, so they won't be overridden)
- split pipelines into multiple lines
- remove "echo" that seems to be redundant

All this should help with readability and also result in cleaner diffs
when changes are made.
2 years ago
Ajeet D'Souza 54841248e7
[shell] ALT-C: Use builtin cd to avoid conflicts (#2799) 2 years ago
Jan Warchoł 3312cf525d
[bash] Allow passing args to __fzf_select__ via fzf-file-widget (#2783)
This makes it easier to make customizations, for example instead of

    bind -x '"\C-o\C-i": FZF_CTRL_T_COMMAND="fasd -Rl" FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --tiebreak=index " fzf-file-widget'

it's enough to just

    bind -x '"\C-o\C-i": FZF_CTRL_T_COMMAND="fasd -Rl" fzf-file-widget --tiebreak=index'
2 years ago
Junegunn Choi 5f385d88e0
[zsh] Set up bindings for all three keymaps: emacs, vicmd, and viins
Fix #2694
2 years ago
zsugabubus 205f885d69
[shell] Use cd -- (#2659)
Otherwise directories starting with '-' may treated as options.
3 years ago
Junegunn Choi f799b568d1
[bash] Suppress error message from 'bind'
Fix #2618
3 years ago
a1346054 8f899aaf8a use proper bash-style notation 3 years ago
a1346054 e53b4bb439 always use [[ ... ]] and not [ ... ] in bash completions 3 years ago
Jannik Vieten f4e1ed25f2
[fish] Make widgets work with --option= prefix (#2383)
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
3 years ago
Marlon Richert 43b3b907f8
[zsh] Don't run precmd hooks in cd widget (#2340)
`precmd` hooks expect the Zsh Line Editor to not be active.
Running these when the ZLE is active can lead to unpredictable results.
See https://github.com/marlonrichert/zsh-autocomplete/issues/180
3 years ago
Ruslan Sayfutdinov 9ddf5c72be
[zsh] Properly reset prompt after completion (#2318) 3 years ago
Junegunn Choi 37708ad9cd
Revert "[zsh] Use shell redirection (#2281)"
This reverts commit e9bc7331bd.

The change is no longer necessary since 090dee8.
3 years ago
Junegunn Choi b234647a63
[shell] Disable CTRL-Z
Fix #2289
3 years ago
林千里 e9bc7331bd
[zsh] Use shell redirection (#2281)
zsh sends SIGCONT when running fzf in a pipe in certain cases,
causing mouse mode to become disabled

Fix #2101
3 years ago
Junegunn Choi 00f4551a7b
Revert "[zsh] Reload shared history before searching (#2251)"
This reverts commit b62a74b315.

https://github.com/junegunn/fzf/pull/2251#issuecomment-740551383
3 years ago
Martin Polden b62a74b315
[zsh] Reload shared history before searching (#2251) 4 years ago
ratijas c61eb94b3f
[zsh] Declare variable as local before assignment (#2266) 4 years ago
Tomas Janousek 7bd99a22ee [bash-completion] Fix endless loop when completion.bash sourced twice
I forgot to add the "not _fzf" check into __fzf_orig_completion, so
invoking it twice would rewrite the _fzf_orig_completion_xxx variables
and then cause an endless loop when completion is requested.

Fixes: ef2c29d5d4 ("[bash-completion] Optimize __fzf_orig_completion_filter")
4 years ago
Tomas Janousek 75b8cca3b3 [bash-completion] Unexport _fzf_orig_completion_* variables 4 years ago
Tomas Janousek ef2c29d5d4 [bash-completion] Optimize __fzf_orig_completion_filter
Commit d4ad4a25 slowed loading of completion.bash significantly (on my
laptop from 10 ms to 30 ms), then 54891d11 improved that (to 20 ms) but
it still stands out as the heavy part of my .bashrc.

Rewriting __fzf_orig_completion_filter to pure bash without forking to
sed/awk brings this back under 10 ms.

before:

    $ HISTFILE=/tmp/bashhist hyperfine 'bash --rcfile shell/completion.bash -i'
    Benchmark #1: bash --rcfile shell/completion.bash -i
      Time (mean ± σ):      21.2 ms ±   0.3 ms    [User: 24.9 ms, System: 6.4 ms]
      Range (min … max):    20.7 ms …  23.3 ms    132 runs

after:

    $ HISTFILE=/tmp/bashhist hyperfine 'bash --rcfile shell/completion.bash -i'
    Benchmark #1: bash --rcfile shell/completion.bash -i
      Time (mean ± σ):       9.6 ms ±   0.3 ms    [User: 8.0 ms, System: 2.2 ms]
      Range (min … max):     9.3 ms …  11.4 ms    298 runs

Fixes: d4ad4a25db ("[bash-completion] Fix default alias/variable completion")
Fixes: 54891d11e0 ("[bash-completion] Minor optimization")
4 years ago
Tomas Janousek 218b3c8274 [bash-completion] Move -F/_fzf filter to __fzf_orig_completion_filter
This prevents mistakes like the one fixed by the previous commit, and
also speeds bash startup a tiny bit:

before:

    $ HISTFILE=/tmp/bashhist hyperfine 'bash --rcfile shell/completion.bash -i'
    Benchmark #1: bash --rcfile shell/completion.bash -i
      Time (mean ± σ):      22.4 ms ±   0.6 ms    [User: 28.7 ms, System: 7.8 ms]
      Range (min … max):    21.7 ms …  25.2 ms    123 runs

after:

    $ HISTFILE=/tmp/bashhist hyperfine 'bash --rcfile shell/completion.bash -i'
    Benchmark #1: bash --rcfile shell/completion.bash -i
      Time (mean ± σ):      21.2 ms ±   0.3 ms    [User: 24.9 ms, System: 6.4 ms]
      Range (min … max):    20.7 ms …  23.3 ms    132 runs
4 years ago
Tomas Janousek db9cb2ddda [bash-completion] Avoid empty _a, _v completions
This doesn't look right:

    $ complete | grep ' _.$'
    complete _a
    complete _v

The __fzf_orig_completion_filter invocation in _fzf_setup_completion
needs the /-F/ filter, just like all the other invocations.

Fixes: d4ad4a25db ("[bash-completion] Fix default alias/variable completion")
4 years ago
Andrew Zhou 6c9adea0d3
[fish] Fix parser handling of option-like args (#2208)
Fixes error when option-like args are parsed (e.g. "-1").
4 years ago
Elvan Owen 2986e64a49 [completion] Make host completion handle source files without EOL 4 years ago
Junegunn Choi 9dfca77c36
[zsh] Keep current $BUFFER on ALT-C
Ideally, we could only use `print -sr` to update the command history.
However, the "cd" command by ALT-C is added to the history only after we
finalize the current command by pressing an additional enter key.

i.e. The cd command from ALT-C is not visible when you hit Up arrow. But
it appears once you hit enter key.

So when the current buffer is empty, we use `zle accept-line` so that
the command history is immediately updated.

Close #2200
4 years ago
octaltree 82c4af2902
[zsh] Record cd execution in history (#2193) 4 years ago
Yuji Nakao d785135606
[zsh] Fix the regular expression (#2140)
Fix the regular expression to capture the command containing asterisk.
4 years ago
Junegunn Choi f81feb1e69
Revert file mode of key-bindings.zsh 4 years ago
Slaven Rezić e6d33f77da
[zsh] Make CTRL-R work with older Perls (#2003)
s///r is only available since perl 5.14. The Perl oneliner
was changed to work with older Perls, possibly even with 5.000.

Fix #2001
4 years ago
Junegunn Choi 6e464ebd9b
Remove dead code 4 years ago
Junegunn Choi c329279339
[completion] Make kill completion more consistent with the others
Support both ordinary completion trigger and empty trigger

    kill <tab>
    kill foo**<tab>

Close #1988
Close #385
4 years ago
Junegunn Choi dea206b023
[zsh-completion] Fix error with backslash-prefixed commands
Fix #1973
Fix #1974
Fix #1975
4 years ago
Junegunn Choi 21f94ee800 [fzf-tmux] Split zsh variable expansion for old zsh
The following code works in zsh 5.8 but not in 5.4

  ${(Q)${(Z+n+)FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}}}
4 years ago
Junegunn Choi 540bfd7a72 [fzf-tmux] Fall back to plain fzf when split failed 4 years ago
Junegunn Choi bf65e8cd12 [fzf-tmux] Add option to start fzf in tmux popup window
Requires latest tmux built from source (e.g. brew install tmux --HEAD)

Examples:

  # 50%/50% width and height on the center of the screen
  fzf-tmux -p

  # 80%/80%
  fzf-tmux -p80%

  # 80%/40%
  fzf-tmux -p80%,40%

  # Separate -w and -h
  fzf-tmux -w80% -h40%

  # 80%/40% at position (0, 0)
  fzf-tmux -w80% -h40% -x0 -y0

You can configure key bindings and fuzzy completion to open in tmux
popup window like so:

  FZF_TMUX_OPTS='-p 80%'
4 years ago
Roman Perepelitsa b1b916ce15
[zsh] Ensure that fzf code always parses the same way (#1944)
At the top of each zsh file options are set to their
standard values (those marked with <Z> in `man zshoptions`)
and `aliases` option is disabled.

At the bottom of the file the original options are restored.

Fix #1938
4 years ago
Junegunn Choi 18261fe31c
[shell] Update CTRL-R to remove duplicate commands
Close #1940
Related: #1363 #749 #270 #49 #88 #492 #600
4 years ago
Chitoku 079046863c
[zsh-completion] Fix a bug where _fzf_complete did not iterate through args (#1936) 4 years ago
Junegunn Choi 14f90502a4
[bash] Restore --nth option in CTRL-R 4 years ago