Commit Graph

90 Commits (e44f64ae923c9fc756b2effe80a31d97814aade9)

Author SHA1 Message Date
Nachum Barcohen e44f64ae92
Add Helix editor to bash autocompletion (#3137) 1 year ago
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
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 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
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
Jonathan Zacsh c79c306adb
[bash] Fix `fzf-tmux` to have `fzf`'s completion (#2871) 2 years ago
Junegunn Choi f799b568d1
[bash] Suppress error message from 'bind'
Fix #2618
3 years ago
a1346054 e53b4bb439 always use [[ ... ]] and not [ ... ] in bash completions 3 years ago
Junegunn Choi b234647a63
[shell] Disable CTRL-Z
Fix #2289
3 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
Elvan Owen 2986e64a49 [completion] Make host completion handle source files without EOL 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 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
Junegunn Choi 50b7608f9d
Change custom fuzzy completion API
To make it easier to write more complex fzf options. Although this
does not break backward compatibility, users are encouraged to update
their code accordingly.

  # Before
  _fzf_complete "FZF_ARG1 FZF_ARG2..." "$@" < <(
    # Print candidates
  )

  # After
  _fzf_complete FZF_ARG1 FZF_ARG2... -- "$@" < <(
    # Print candidates
  )
4 years ago
Junegunn Choi baf882ace7
[completion] Use file redirection instead of pipe
This change allows the completion system of bash and zsh to return
before the input process completes.

Related #1887
4 years ago
Junegunn Choi 9897ee9591
[bash] Strip trailing whitespace on kill completion 4 years ago
Junegunn Choi 5215415315
[completion] Allow users to customize fzf options via _fzf_comprun
Related #1809 #1850
4 years ago
Junegunn Choi 54891d11e0
[bash-completion] Minor optimization 4 years ago
Hiroki Konishi 2a60edcd52
Make pointer and multi-select marker customizable (#1844)
Add --pointer and --marker option which can provide additional context to the user
4 years ago
Junegunn Choi d4ad4a25db
[bash-completion] Fix default alias/variable completion
Fix #1795
4 years ago
Henré Botha 5e42b1c9f8 [ssh completion] Skip only aliases matching * (#1788)
This commit fixes a bug where lines that declare multiple hostnames get
omitted from completion entirely if one of the hostnames matches *. For
example:

	Host foo.com bar.dev baz.*
5 years ago
David Gray 77cb906dfe
[completion] Add support for HostName lines in ~/.ssh/config (#1785)
Close #1783
5 years ago
John Purnell 357e82e51b [completion] Ignore hg repos (#1777)
* Update completion.bash
* Update completion.zsh
5 years ago
Junegunn Choi a5a97be017
[bash-completion] Properly handle exit event
Related #1704
5 years ago
Junegunn Choi 5c7dcaffe8
[bash-completion] _fzf_setup_completion to retain previous options 5 years ago
Junegunn Choi 5095899245
[bash-completion] Add _fzf_setup_completion to enable fuzzy completion
While we can attach `_fzf_path_completion` or `_fzf_dir_completion` to
any command using the standard bash complete command, the functionality
of the existing completion function is lost.

Use _fzf_setup_completion if you want to extend the existing function
with fuzzy completion instead of completely replacing it.

e.g. _fzf_setup_completion path kubectl
5 years ago
Jesus Briales 03e8ed4d88 [bash-completion] Fix custom completion with dynamic loader enabled for non-standard command names (#1564)
Related to #1170.

Fix the solution for commands with non-standard names
where `$cmd` and `$orig_cmd` differ. e.g. `s.foo` -> `s_foo`
5 years ago
Rui Coelho 3bd8441079
[completion] Look up on ~/.ssh/config.d/* files when doing ssh host complete (#1420) 5 years ago
Junegunn Choi 8cf45a5197
[shell] Skip loading completion code on non-interactive shell
This change is not required if you use the install script to generate
~/.fzf.bash or ~/.fzf.zsh which already has the proper guard statement.

Close #1474
5 years ago
Jay 6de1ad9d3d [completion] Filter out non-hostnames in SSH config file (#1329)
* Correctly exclude SSH config options with Host

SSH config files have 14 options containing 'Host'.
Previously The zsh and bash completion scripts would include lines
containing these options when doing command-line completion of SSH hosts
with `ssh **`.

This commit fixes that problem by only including lines with 'host '.

* Don't autocomplete SSH hostnames using ?

SSH config files support ? as well as * for wildcards in Host lines.
This commit excludes lines containing ? for zsh/bash command line
completeion using `ssh **`
6 years ago
ptzz 2b19c0bc68 [bash/zsh] Fix missing fuzzy completions (#1303)
* [bash/zsh] Fix missing fuzzy completions

`cat foo**<TAB>` did not display the file `foobar` if there was a directory
named `foo`.

Fixes #1301

* [zsh] Evaluate completion prefix

  cat $HOME**
  cat ~username**
  cat ~username/foo**
6 years ago
ptzz 1fb0fbca58 [bash] Do not print error when falling back to default completion (#1279)
Fixes #1278
6 years ago
Junegunn Choi 87504a528e
[bash] Fix infinite loop on tab completion
awk may not set OFS to match FS depending on the implementation.

Close #1227
6 years ago
Avindra Goolcharan 7add75126d ZSH and Bash completion: remove shebang (#1248)
Shebangs are only for files that are directly executable. In cases
where files are only sourced (such as completion scripts), these
are unneeded.
6 years ago
Junegunn Choi cce6aef557
[bash] Fix extra space issue of dynamic completion with 'nospace'
Close #1203
6 years ago
Junegunn Choi d6588fc835
[bash-completion] Fix custom completion with dynamic loader enabled
After _completion_loader is called, instead of loading the entire
completion.bash file, just restore the fzf completion for the current
command. `_fzf_orig_completion_$cmd` is only set if _completion_loader
actually changed the completion options to avoid infinite loop.

Close #1170
7 years ago
Igor Urazov eaf6eb8978 [completion] Ensure ps called as command (#1098)
When `ps` is aliased for something uncommon, like `alias ps=grc ps` which colorizes ps output, the output of `ps` can be unexpected and/or undesired.

This change makes ps to be always executed as command, even if it's aliased.
7 years ago
Andrey Chernih 80a21f7a75 [completion] Fix known_hosts completion for custom port number (#1092)
Handles records like "[20.20.7.168]:9722 ssh-rsa ..."

This is a standard format for servers running on custom port according to http://man.openbsd.org/sshd.8#SSH_KNOWN_HOSTS_FILE_FORMAT

    A hostname or address may optionally be enclosed within ‘[’ and ‘]’
    brackets then followed by ‘:’ and a non-standard port number.
7 years ago
Josh Pencheon 45d4c57d91 [completion] Include host aliases in ssh completion (#1062) 7 years ago
Junegunn Choi 9d2c6a95f4
Revert "[bash] Do not append space when path completion is cancelled"
This reverts commit 376a76d1d3 as it
affects normal completion
7 years ago
Junegunn Choi 376a76d1d3
[bash] Do not append space when path completion is cancelled
Close #990
7 years ago
Junegunn Choi a5862d4b9c
[bash-completion] Use -o dirnames instead of -o plusdirs
Close #903
Related #135
7 years ago