deleted: .config/apps-list.md modified: .config/btop/btop.conf deleted: .config/config.kdl new file: .config/fish/completions/fisher.fish new file: .config/fish/completions/fzf_configure_bindings.fish new file: .config/fish/conf.d/fzf.fish new file: .config/fish/fish_plugins modified: .config/fish/fish_variables new file: .config/fish/functions/_fzf_configure_bindings_help.fish new file: .config/fish/functions/_fzf_extract_var_info.fish new file: .config/fish/functions/_fzf_preview_changed_file.fish new file: .config/fish/functions/_fzf_preview_file.fish new file: .config/fish/functions/_fzf_report_diff_type.fish new file: .config/fish/functions/_fzf_report_file_type.fish new file: .config/fish/functions/_fzf_search_directory.fish new file: .config/fish/functions/_fzf_search_git_log.fish new file: .config/fish/functions/_fzf_search_git_status.fish new file: .config/fish/functions/_fzf_search_history.fish new file: .config/fish/functions/_fzf_search_processes.fish new file: .config/fish/functions/_fzf_search_variables.fish new file: .config/fish/functions/_fzf_wrapper.fish new file: .config/fish/functions/fisher.fish new file: .config/fish/functions/fzf_configure_bindings.fish new file: .config/fish/functions/y.fish new file: .config/fish/functions/yz.fish new file: ".config/fish/functions/\320\275\321\217.fish" modified: .config/kitty/kitty.conf modified: .config/niri/config.kdl modified: .config/nvim/lazy-lock.json new file: .config/nvim/lua/plugins/luasnip.lua new file: .config/nvim/lua/plugins/markview.lua new file: .config/nvim/lua/plugins/marp-nvim.lua new file: .config/nvim/lua/plugins/nvim-snippy.lua new file: .config/nvim/lua/plugins/render-markdown.lua deleted: .config/nwg-look/config deleted: .config/zathura/zathurarc modified: apps-list.md new file: background renamed: .config/mimeapps.list -> mimeapps.list renamed: .config/pavucontrol.ini -> pavucontrol.ini deleted: sing-box-03.json renamed: .config/user-dirs.dirs -> user-dirs.dirs renamed: .config/user-dirs.locale -> user-dirs.locale
39 lines
1.6 KiB
Fish
39 lines
1.6 KiB
Fish
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
|
|
|
|
if not set --query fzf_history_time_format
|
|
# Reference https://devhints.io/strftime to understand strftime format symbols
|
|
set -f fzf_history_time_format "%m-%d %H:%M:%S"
|
|
end
|
|
|
|
# Delinate time from command in history entries using the vertical box drawing char (U+2502).
|
|
# Then, to get raw command from history entries, delete everything up to it. The ? on regex is
|
|
# necessary to make regex non-greedy so it won't match into commands containing the char.
|
|
set -f time_prefix_regex '^.*? │ '
|
|
# Delinate commands throughout pipeline using null rather than newlines because commands can be multi-line
|
|
set -f commands_selected (
|
|
builtin history --null --show-time="$fzf_history_time_format │ " |
|
|
_fzf_wrapper --read0 \
|
|
--print0 \
|
|
--multi \
|
|
--scheme=history \
|
|
--prompt="History> " \
|
|
--query=(commandline) \
|
|
--preview="string replace --regex '$time_prefix_regex' '' -- {} | fish_indent --ansi" \
|
|
--preview-window="bottom:3:wrap" \
|
|
$fzf_history_opts |
|
|
string split0 |
|
|
# remove timestamps from commands selected
|
|
string replace --regex $time_prefix_regex ''
|
|
)
|
|
|
|
if test $status -eq 0
|
|
commandline --replace -- $commands_selected
|
|
end
|
|
|
|
commandline --function repaint
|
|
end
|