Skip to content

Commit 289153d

Browse files
authored
Show preview of entire command in history search (#125)
Long commands get truncated in the fzf finder, while the spacing of multi-line commands are messed up. To remedy this, show a preview of the entire command at the bottom.
1 parent 8a299b4 commit 289153d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Use `fzf.fish` to interactively find and insert into the command line:
4747

4848
- **Search input:** the command history from all interactive sessions of Fish
4949
- **Key binding and mnemonic:** <kbd>Ctrl</kbd>+<kbd>R</kbd> (`R` for reverse-i-search)
50+
- **Preview window:** the entire command, wrapped
5051

5152
### A shell variable
5253

functions/__fzf_search_history.fish

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ function __fzf_search_history --description "Search command history. Replace the
44
set command_with_ts (
55
# Reference https://devhints.io/strftime to understand strftime format symbols
66
builtin history --null --show-time="%m-%d %H:%M:%S | " |
7-
fzf --read0 --tiebreak=index --query=(commandline) |
7+
fzf --read0 --tiebreak=index --query=(commandline) \
8+
# preview current command in a window at the bottom 3 lines tall
9+
--preview="echo {4..}" \
10+
--preview-window="bottom:3:wrap" |
811
string collect
912
)
1013

0 commit comments

Comments
 (0)