# Scrolling will behave similarly to CTRL-E and CTRL-Y of vim
fzf --bind scroll-up:offset-up,scroll-down:offset-down \
--bind ctrl-y:offset-up,ctrl-e:offset-down \
--scroll-off=5
Close#3456
* [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>
Close#3228
* Works inside and outside of tmux
* There is a problem where fzf unnecessarily displays the scroll offset
indicator at the topbright of the screen when the image just fits the
preview window. This is because `kitty icat` generates an extra line
after the image area.
# A 5-row images; an extra row at the end confuses fzf
["\e_Ga ... \e[9C̅̅ࠪ̅̍ࠪ̅̎ࠪ̅̐ࠪ̅̒ࠪ̅̽ࠪ̅̾ࠪ̅̿ࠪ̅͆ࠪ̅͊ࠪ̅͋ࠪ\n",
"\r\e[9C̍̅ࠪ̍̍ࠪ̍̎ࠪ̍̐ࠪ̍̒ࠪ̍̽ࠪ̍̾ࠪ̍̿ࠪ̍͆ࠪ̍͊ࠪ̍͋ࠪ\n",
"\r\e[9C̎̅ࠪ̎̍ࠪ̎̎ࠪ̎̐ࠪ̎̒ࠪ̎̽ࠪ̎̾ࠪ̎̿ࠪ̎͆ࠪ̎͊ࠪ̎͋ࠪ\n",
"\r\e[9C̐̅ࠪ̐̍ࠪ̐̎ࠪ̐̐ࠪ̐̒ࠪ̐̽ࠪ̐̾ࠪ̐̿ࠪ̐͆ࠪ̐͊ࠪ̐͋ࠪ\n",
"\r\e[9C̒̅ࠪ̒̍ࠪ̒̎ࠪ̒̐ࠪ̒̒ࠪ̒̽ࠪ̒̾ࠪ̒̿ࠪ̒͆ࠪ̒͊ࠪ̒͋ࠪ\n",
"\r\e[39m\e8"]
* Example:
fzf --preview='
if file --mime-type {} | grep -qF 'image/'; then
# --transfer-mode=memory is the fastest option but if you want fzf to be able
# to redraw the image on terminal resize or on 'change-preview-window',
# you need to use --transfer-mode=stream.
kitty icat --clear --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 {}
else
bat --color=always {}
fi
'
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>
`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]: ec8113b986/CHANGES (L1511)
To enable: `shopt -s cmdhist lithist; HISTTIMEFORMAT='%F %T '`.
armv8l is always 32-bit and should implement the armv7 ISA, so
just use the same filename as for armv7.
This avoids wrongly building a 64-bit binary because of an incorrect assumption
of what 'armv8l' is (a 32-bit system).
Obviously, we should not then build a 64-bit (arm64) binary. Especially
given armv8l is often used in arm32-on-arm64 chroots to build stuff for
weaker-powered arm32 devices.
Signed-off-by: Sam James <sam@gentoo.org>
* fix: turn off remain-on-exit only on fzf-tmux pane
Using `fzf-tmux` overwrites `remain-on-exit` for all panes in a window,
if it is only set globally or at a higher scope than window.
set-option -wg remain-on-exit on
set-option -s remain-on-exit on
This makes other panes in that window close immediately on exit after
using `fzf-tmux`, even though I expect them to remain open.
Since TMux 3.0, `remain-on-exit` is a pane option that can be set via
`set-option -p`. This will limit the option's scope to just the
`fzf-tmux` pane, thus allowing us to close it immediately without
overriding `remain-on-exit` on other panes in the window.
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
Link: 11e69f6025/CHANGES (L753-L760)
Link: https://github.com/tmux/tmux/releases/tag/3.0
Related: https://github.com/junegunn/fzf/issues/3397
* fix: turn off synchronize-panes only on fzf-tmux pane
Similar reason to 482fd2b (fix: turn off remain-on-exit only on fzf-tmux
pane, 2023-08-24).
Limit scope on which option is set to bare minimum.
Have confirmed this will not feed input back to other panes which are
set to be synchronized. However, note that this will not stop `fzf-tmux`
from being launched by two synchronized panes in parallel.
Link: https://github.com/junegunn/fzf/issues/3397#issuecomment-1689295351
---------
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>