Update fish

This commit is contained in:
Hydroxycarbamide 2023-04-03 16:40:39 +02:00
parent f5306476ea
commit 123172a72b
16 changed files with 382 additions and 41 deletions

View file

@ -1,23 +1,29 @@
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
builtin history merge
# it errors out if called in private mode
if test -z "$fish_private_mode"
builtin history merge
end
set command_with_ts (
# 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 current command using fish_ident in a window at the bottom 3 lines tall
--preview="echo -- {4..} | fish_indent --ansi" \
--preview-window="bottom:3:wrap" \
$fzf_history_opts |
string collect
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
set command_selected (string split --max 1 " │ " $command_with_ts)[2]
commandline --replace -- $command_selected
commandline --replace -- $commands_selected
end
commandline --function repaint