When just checking whether a function is already defined or not, it’s not
necessary to print out it’s definition (should it be defined).
bash’s `declare` provides the `-F`-option (which implies `-f`), which should
give a minor performance improvement
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
* Explicitly specify the list of fields for consistent experience
* Add fallback command for BusyBox (Close#3219)
* Apply `--header-lines=1` to show the column header
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")
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")
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
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")
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%'
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
)
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.*
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
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
* 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 **`
* [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**