From 8600374371f91843064441113f4023cda1730877 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sat, 18 Mar 2023 16:40:57 -0300 Subject: General fish fixes and updates --- .config/fish/functions/_fzf_search_history.fish | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .config/fish/functions/_fzf_search_history.fish (limited to '.config/fish/functions/_fzf_search_history.fish') diff --git a/.config/fish/functions/_fzf_search_history.fish b/.config/fish/functions/_fzf_search_history.fish new file mode 100644 index 00000000..d795c5c7 --- /dev/null +++ b/.config/fish/functions/_fzf_search_history.fish @@ -0,0 +1,30 @@ +function _fzf_search_history --description "Search command history. Replace the command line with the selected command." + # history merge incorporates history changes from other fish sessions + # it errors out if called in private mode + if test -z "$fish_private_mode" + builtin history merge + end + + # Delinate commands throughout pipeline using null rather than newlines because commands can be multi-line + set commands_selected ( + # Reference https://devhints.io/strftime to understand strftime format symbols + builtin history --null --show-time="%m-%d %H:%M:%S │ " | + _fzf_wrapper --read0 \ + --print0 \ + --multi \ + --tiebreak=index \ + --query=(commandline) \ + --preview="echo -- {4..} | fish_indent --ansi" \ + --preview-window="bottom:3:wrap" \ + $fzf_history_opts | + string split0 | + # remove timestamps from commands selected + string replace --regex '^\d\d-\d\d \d\d:\d\d:\d\d │ ' '' + ) + + if test $status -eq 0 + commandline --replace -- $commands_selected + end + + commandline --function repaint +end -- cgit v1.2.3