Age | Commit message (Collapse) | Author |
|
* Fix #3488
* Handle inline comments in hosts file
|
|
Fix #3484
|
|
Fix #2094
|
|
Just like with the other shells, exit fish to, if called from a non-interactive
shell.
We cannot use `return`, as older versions of fish (namely < 3.4.0) did not
support to use `return` in `.`-scripts (this was only added with fish commit
3359e5d2e9bcbf19d1652636c8e448a6889302ae).
Unlike in POSIX, fish’s `exit` is however documented to no cause the calling
shell to exit when executed in a sourced script (see:
https://github.com/fish-shell/fish-shell/blob/0f70b2c0d310d97b5956b5360ad6cbc548baf72d/doc_src/cmds/exit.rst?plain=1#L20
)
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
|
|
|
|
When bash-completion (and thus `_known_hosts_real()`) is / is not available this
will typically not change during the lifetime of a shell.
The only exception is if the user would unset `_known_hosts_real()`, but well,
that would be his problem.
So we can easily define `__fzf_list_hosts()` either using `_known_hosts_real()`
or using the old code, and avoid checking every time whether
`_known_hosts_real()` is defined.
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
|
|
If defined, use bash-completions’s `_known_hosts_real()`-function to create the
list of hostnames.
This obviously requires bash-completion to be sourced before fzf.
If not defined, fall back to the previous code.
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
|
|
Just like it’s already done for `_fzf_compgen_path()` and `_fzf_compgen_dir()`
allow a user to easily define his own version of `__fzf_list_hosts()`.
Also add some documentation on the expected “interface” of such custom function.
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
|
|
`__fzf_list_hosts()` seems like a function a user may want to override with some
custom code.
For that reason it should be kept as simple as possible, that is printing only
hostnames, one per line, optionally in some sorting.
The handling of adding a `username@` (which is then the same for each line), if
any, would unnecessarily complicate that for people who want to override the
function.
Therefore this commit moves that to the places where it's actually used (as of
now only `_fzf_complete_ssh()`).
This also saves any such handling for `_fzf_host_completion()`, where this isn’t
needed at all.
Right now it comes at a cost, namely an extra invocation of `awk` in the
`_fzf_complete_ssh()`-case.
However, it should be easily possible to improve `__fzf_list_hosts()` to no
longer need the final `awk` in the pipeline there.
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
|
|
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
|
|
This commit causes all simple commands that are not built-ins or functions to be
invoked via `command` in order to protect them from alias substitution or from
accidentally taking functions of the same name.
It was decided to not “protect” `fzf` and `fzf-tmux` for now.
Maybe a better solution should be implemented for that in the future.
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
|
|
* [bash] bring fzf’s own bash completion up to date
This orders and groups completed options and values in just as they appear in
the code respectively, for some option values, as they’d be printed in the
`--help`-output.
It does not add support for completion of `:` right after values that support an
optional `:some-further-value` postfix.
Neither does it add support for the `--option=value`-style.
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
* [bash] drop unnecessary code in handling `history`
Presumably, the dropped code is not needed for any effect, thus drop it.
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
---------
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
|
|
* [bash] return instead of not executing an if-block, when non-interactive
This should keep the code more readable, be less error prone (accidentally doing
something outside the if-block and aligns the code with what’s already done for
zsh.
`0` is returned, because it shall not be considered an error when the script is
(accidentally) sourced from a non-interactive shell.
If executed as a script (rather than sourced), the results are not specified by
POSIX but depend on the shell, with bash giving an error in that case.
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
* [shell] exit immediately when called from non-interactive shell
The shell execution environment shouldn’t be modified at all, when called from a
non-interactive shell.
It shall be noted that the current check may become error prone for bash, namely
in case there should ever be a differentiation between `i` and `I` in the
special variable `-` and bash’s `nocasematch`-shell-option be used.
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
|
|
* Use the all-compatible mawk `-W version` option.
https://github.com/junegunn/fzf/pull/3313#issuecomment-1747934690.
* Run the command and not a function consistently with #3462.
The version check bash code relies on the following mawk source code,
extracted from mawk 1.3.4 20230322.
```
version.c:
18- #include "init.h"
19- #include "patchlev.h"
20-
21: #define VERSION_STRING \
22- "mawk %d.%d%s %s\n\
23- Copyright 2008-2022,2023, Thomas E. Dickey\n\
24- Copyright 1991-1996,2014, Michael D. Brennan\n\n"
....
30- void
31- print_version(FILE *fp)
32- {
33: fprintf(fp, VERSION_STRING, PATCH_BASE, PATCH_LEVEL, PATCH_STRING, DATE_STRING);
34- fflush(fp);
35-
36- #define SHOW_RANDOM "random-funcs:"
patchlev.h:
13- /*
14- * $MawkId: patchlev.h,v 1.128 2023/03/23 00:23:57 tom Exp $
15- */
16: #define PATCH_BASE 1
17- #define PATCH_LEVEL 3
18- #define PATCH_STRING ".4"
19- #define DATE_STRING "20230322"
```
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
|
|
Take two.
* Avoid eval if the prefix contains `:=`
* This is not to evaluate variable assignment. e.g. ${FOO:=BAR}
* [zsh] Prevent `>(...)` form
* Suppress error message from prefix evaluation
* Stop completion when prefix evaluation failed
Thanks to @calestyo
|
|
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>
|
|
Do not attempt to provide fuzzy completion if the prefix contains a
pattern that may start an arbitraty command.
* $(...)
* `...`
* <(...)
Close #3459
|
|
https://github.com/junegunn/fzf/commit/e0b29e437be458066fca4dab39b282dfc11466f6
|
|
`find`’s `-path`-option is described to use shell patterns (i.e. POSIX’ pattern
matching notation).
In that, `.` is not a special character, thus escaping it shouldn’t be
necessary.
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
|
|
While awk is POSIX, perl isn't pre-installed on all *nix flavors.
This commit eliminates the mandatory dependency on perl by using awk
when perl is not available.
Related: #3295, #3309, #3310.
Test suite passed:
* `make error` all test sections 'PASS'
* `make docker-test` 215 runs, 1884 assertions, 0 failures, 0 errors, 0 skips.
Manually tested in the following environments:
* Linux amd64 with bash 3.2, 4.4, 5.2; gawk -P, one true awk, mawk, busybox awk.
* macOS Catalina, bash 3.2, macOS awk 20070501.
**Performance comparison:**
Mawk turned out the fastest, then perl.
One true awk's implementation should be the closest to macOS awk.
Test data: 230 KB history, 15102 entries, including multi-line and duplicates.
Linux, bash 4.4. Times in milliseconds.
| Command | Mean | Min | Max | Relative |
| :--- | ---: | ---: | ---: | -------: |
| `mawk 1.3.4` | 22.9 | 22.3 | 25.6 | **1.00** |
| `perl 5.26.1` | 34.3 | 33.6 | 35.1 | 1.49 |
| `one true awk 20221215` | 41.9 | 40.6 | 46.3 | 1.83 |
| `gawk 5.1.0` | 46.1 | 44.4 | 50.3 | 2.01 |
| `busybox awk 1.27.0` | 64.8 | 63.2 | 70.0 | 2.82 |
**Other Notes**
A bug affects bash, which fails restoring a saved multi-line history entry as a single entry. Bug fixed in version 5.0.[^1]
While developing this PR I discovered two unsubmitted issues affecting the current perl script. The output stream ends with `$'\n\0000'` instead of `$'\0000'`. Because of this, the script does not deduplicate a duplicated entry located at the end of the history list; therefore fzf displays two identical (not necessarily adjacent) entries. A minor point about the first issue is that the top fzf entry ends with a dangling line feed symbol, which is visible in the terminal.
[^1]: https://github.com/bminor/bash/blob/ec8113b9861375e4e17b3307372569d429dec814/CHANGES#L1511
To enable: `shopt -s cmdhist lithist; HISTTIMEFORMAT='%F %T '`.
|
|
Without the option, you may get suboptimal results if you have many
paths with spaces in their names.
e.g. https://github.com/junegunn/fzf/issues/2909#issuecomment-1207690770
Close #3433
|
|
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
|
|
Fix #3382
|
|
* 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
|
|
Bat is a common alternative to cat, it's even referenced multiple times
in fzf docs. This makes `bat **` work by default.
|
|
Close #3145
|
|
|
|
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
|
|
`builtin cd` of fish doesn't support `cd -`
Close #2967
|
|
* Fix bash completion var or aliase containing newlines
* Support for various bash declare options
Co-authored-by: knutze <shakte@gmail.com>
|
|
Close #2909
Close #2930
|
|
Fix #2931
|
|
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
|
|
|
|
Close #2474
Close #2583
|
|
'kill **<tab>' instead of 'kill <tab>' just like any other completions.
Close #2716
Close #385
|
|
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.
|
|
|
|
- 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.
|
|
|
|
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'
|
|
Fix #2694
|
|
Otherwise directories starting with '-' may treated as options.
|
|
Fix #2618
|
|
|
|
|
|
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
|
|
`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
|
|
|
|
This reverts commit e9bc7331bde238e84f24b76ebb1f5e18799b15c4.
The change is no longer necessary since 090dee8.
|