Avoid performance hit caused by pre-saving by presaving in the background

This commit is contained in:
David Dworken 2023-09-17 14:11:44 -07:00
parent 1ab61f1d7d
commit 1d7ba41289
No known key found for this signature in database
3 changed files with 6 additions and 3 deletions

View File

@ -2,7 +2,8 @@ function _hishtory_post_exec --on-event fish_preexec
# Runs after <ENTER>, but before the command is executed
set --global _hishtory_command $argv
set --global _hishtory_start_time (date +%s)
hishtory presaveHistoryEntry bash "$_hishtory_command" $_hishtory_start_time
hishtory presaveHistoryEntry bash "$_hishtory_command" $_hishtory_start_time & # Background Run
# hishtory presaveHistoryEntry bash "$_hishtory_command" $_hishtory_start_time # Foreground Run
end
set --global _hishtory_first_prompt 1

View File

@ -15,7 +15,8 @@ function __hishtory_precommand() {
# Run before every command
HISHTORY_START_TIME=`date +%s`
if ! [ -z "BASH_COMMAND " ] && [ "$BASH_COMMAND" != "__hishtory_postcommand" ]; then
hishtory presaveHistoryEntry bash "$BASH_COMMAND" $HISHTORY_START_TIME
(hishtory presaveHistoryEntry bash "$BASH_COMMAND" $HISHTORY_START_TIME &) # Background Run
# hishtory presaveHistoryEntry bash "$BASH_COMMAND" $HISHTORY_START_TIME # Foreground Run
fi
}
trap "__hishtory_precommand" DEBUG

View File

@ -10,7 +10,8 @@ function _hishtory_add() {
_hishtory_command=$1
_hishtory_start_time=`date +%s`
if ! [ -z "$_hishtory_command " ]; then
hishtory presaveHistoryEntry zsh "$_hishtory_command" $_hishtory_start_time
(hishtory presaveHistoryEntry zsh "$_hishtory_command" $_hishtory_start_time &) # Background Run
# hishtory presaveHistoryEntry zsh "$_hishtory_command" $_hishtory_start_time # Foreground Run
fi
}