Fix removing failed commands from history
This commit is contained in:
parent
e00ea6b65d
commit
e50cc7ae6a
1 changed files with 5 additions and 29 deletions
|
|
@ -61,23 +61,7 @@
|
|||
#alias cal='ncal -b -M'
|
||||
alias myip='dig +short myip.opendns.com @resolver1.opendns.com'
|
||||
|
||||
function hm -d 'merge history and delete failed commands'
|
||||
history --merge
|
||||
|
||||
if test -z "$fish_private_mode" && test -e "$__fish_user_data_dir/successful_commands" && test -e "$__fish_user_data_dir/failed_commands"
|
||||
while read line;
|
||||
if ! grep -qFx $line "$__fish_user_data_dir/successful_commands"
|
||||
set hist_command (echo $line | base64 -d)
|
||||
echo "deleting command: $hist_command"
|
||||
echo "."
|
||||
history delete --exact --case-sensitive $hist_command
|
||||
end
|
||||
end < "$__fish_user_data_dir/failed_commands"
|
||||
echo -n > "$__fish_user_data_dir/successful_commands"
|
||||
echo -n > "$__fish_user_data_dir/failed_commands"
|
||||
end
|
||||
end
|
||||
hm
|
||||
history --merge >/dev/null 2>&1
|
||||
|
||||
# fancy tools
|
||||
if which eza > /dev/null 2>&1
|
||||
|
|
@ -121,18 +105,10 @@
|
|||
|
||||
|
||||
function __postexec --on-event fish_postexec
|
||||
if test $status -ne 0
|
||||
if test -z "$hist_cmd"
|
||||
if test -z "$fish_private_mode"
|
||||
echo $argv[1] | base64 >> "$__fish_user_data_dir/failed_commands"
|
||||
end
|
||||
end
|
||||
else
|
||||
if test -z "$fish_private_mode"
|
||||
echo $argv[1] | base64 >> "$__fish_user_data_dir/successful_commands"
|
||||
end
|
||||
commandline $commandline_buffer
|
||||
set -e commandline_buffer
|
||||
if test $status -ne 0; and test -z "$hist_cmd"; and test -z "$fish_private_mode"
|
||||
#$SHELL -c "
|
||||
history delete --exact --case-sensitive -- $argv[1]
|
||||
#" &
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue