2023-12-31 22:00:56 +01:00
|
|
|
# For detecting color rendering support for this terminal, see #134
|
|
|
|
hishtory getColorSupport
|
|
|
|
export _hishtory_tui_color=$status
|
|
|
|
|
2023-09-15 06:03:36 +02:00
|
|
|
function _hishtory_post_exec --on-event fish_preexec
|
2022-10-19 04:55:41 +02:00
|
|
|
# Runs after <ENTER>, but before the command is executed
|
|
|
|
set --global _hishtory_command $argv
|
2023-11-18 21:19:19 +01:00
|
|
|
set --global _hishtory_start_time (hishtory getTimestamp)
|
2023-10-21 08:23:24 +02:00
|
|
|
hishtory presaveHistoryEntry fish "$_hishtory_command" $_hishtory_start_time &; disown # Background Run
|
2023-09-30 03:21:23 +02:00
|
|
|
# hishtory presaveHistoryEntry fish "$_hishtory_command" $_hishtory_start_time # Foreground Run
|
2022-10-19 04:55:41 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
set --global _hishtory_first_prompt 1
|
|
|
|
|
|
|
|
function __hishtory_on_prompt --on-event fish_prompt
|
|
|
|
# Runs after the command is executed in order to render the prompt
|
|
|
|
# $? contains the exit code
|
|
|
|
set _hishtory_exit_code $status
|
|
|
|
if [ -n "$_hishtory_first_prompt" ]
|
|
|
|
set --global -e _hishtory_first_prompt
|
|
|
|
else if [ -n "$_hishtory_command" ]
|
2023-10-21 08:23:24 +02:00
|
|
|
hishtory saveHistoryEntry fish $_hishtory_exit_code "$_hishtory_command" $_hishtory_start_time &; disown # Background Run
|
2022-10-24 02:35:02 +02:00
|
|
|
# hishtory saveHistoryEntry fish $_hishtory_exit_code "$_hishtory_command" $_hishtory_start_time # Foreground Run
|
2023-10-21 08:23:24 +02:00
|
|
|
hishtory updateLocalDbFromRemote &; disown
|
2022-10-24 00:45:50 +02:00
|
|
|
set --global -e _hishtory_command # Unset _hishtory_command so we don't double-save entries when fish_prompt is invoked but fish_postexec isn't
|
2022-10-19 04:55:41 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-21 08:39:56 +02:00
|
|
|
function __hishtory_on_control_r
|
|
|
|
set -l tmp (mktemp -t fish.XXXXXX)
|
|
|
|
set -x init_query (commandline -b)
|
2024-02-19 21:12:04 +01:00
|
|
|
HISHTORY_TERM_INTEGRATION=1 HISHTORY_SHELL_NAME=fish hishtory tquery $init_query > $tmp
|
2022-10-21 08:39:56 +02:00
|
|
|
set -l res $status
|
|
|
|
commandline -f repaint
|
|
|
|
if [ -s $tmp ]
|
2022-11-20 07:27:08 +01:00
|
|
|
commandline -r -- (cat $tmp)
|
2022-10-21 08:39:56 +02:00
|
|
|
end
|
|
|
|
rm -f $tmp
|
|
|
|
end
|
|
|
|
|
2023-12-20 00:57:32 +01:00
|
|
|
[ (hishtory config-get enable-control-r) = true ] && bind \cr __hishtory_on_control_r
|
|
|
|
|
|
|
|
hishtory completion fish | source
|