From 8663012d9627bb28c39cd1e9c2bf21257bbca71b Mon Sep 17 00:00:00 2001 From: Stefan Imhoff Date: Fri, 10 Feb 2023 16:29:22 +0100 Subject: [PATCH] chore(fisher): remove sponge plugin --- fish/conf.d/sponge.fish | 52 ------------------- fish/fish_plugins | 1 - fish/functions/_sponge_clear_state.fish | 5 -- fish/functions/_sponge_on_exit.fish | 3 -- fish/functions/_sponge_on_postexec.fish | 24 --------- fish/functions/_sponge_on_preexec.fish | 16 ------ fish/functions/_sponge_on_prompt.fish | 5 -- .../_sponge_remove_from_history.fish | 9 ---- fish/functions/sponge_filter_failed.fish | 11 ---- fish/functions/sponge_filter_matched.fish | 11 ---- 10 files changed, 137 deletions(-) delete mode 100644 fish/conf.d/sponge.fish delete mode 100644 fish/functions/_sponge_clear_state.fish delete mode 100644 fish/functions/_sponge_on_exit.fish delete mode 100644 fish/functions/_sponge_on_postexec.fish delete mode 100644 fish/functions/_sponge_on_preexec.fish delete mode 100644 fish/functions/_sponge_on_prompt.fish delete mode 100644 fish/functions/_sponge_remove_from_history.fish delete mode 100644 fish/functions/sponge_filter_failed.fish delete mode 100644 fish/functions/sponge_filter_matched.fish diff --git a/fish/conf.d/sponge.fish b/fish/conf.d/sponge.fish deleted file mode 100644 index e37fe38..0000000 --- a/fish/conf.d/sponge.fish +++ /dev/null @@ -1,52 +0,0 @@ -# Sponge version -set --global sponge_version 1.1.0 - -# Allow to repeat previous command by default -if not set --query --universal sponge_delay - set --universal sponge_delay 2 -end - -# Purge entries both after `sponge_delay` entries and on exit by default -if not set --query --universal sponge_purge_only_on_exit - set --universal sponge_purge_only_on_exit false -end - -# Add default filters -if not set --query --universal sponge_filters - set --universal sponge_filters sponge_filter_failed sponge_filter_matched -end - -# Don't filter out commands that already have been in the history by default -if not set --query --universal sponge_allow_previously_successful - set --universal sponge_allow_previously_successful true -end - -# Consider `0` the only successful exit code by default -if not set --query --universal sponge_successful_exit_codes - set --universal sponge_successful_exit_codes 0 -end - -# No active regex patterns by default -if not set --query --universal sponge_regex_patterns - set --universal sponge_regex_patterns -end - -# Attach event handlers -functions --query \ - _sponge_on_prompt \ - _sponge_on_preexec \ - _sponge_on_postexec \ - _sponge_on_exit - -# Initialize empty state for the first run -function _sponge_install --on-event sponge_install - set --global _sponge_current_command '' - set --global _sponge_current_command_exit_code 0 - set --global _sponge_current_command_previously_in_history false -end - -# Clean up variables -function _sponge_uninstall --on-event sponge_uninstall - _sponge_clear_state - set --erase sponge_version -end diff --git a/fish/fish_plugins b/fish/fish_plugins index 2749b79..88a7be8 100644 --- a/fish/fish_plugins +++ b/fish/fish_plugins @@ -4,4 +4,3 @@ jethrokuan/z jorgebucaran/autopair.fish jorgebucaran/fisher jorgebucaran/replay.fish -meaningful-ooo/sponge diff --git a/fish/functions/_sponge_clear_state.fish b/fish/functions/_sponge_clear_state.fish deleted file mode 100644 index c6a07da..0000000 --- a/fish/functions/_sponge_clear_state.fish +++ /dev/null @@ -1,5 +0,0 @@ -function _sponge_clear_state - set --erase --global _sponge_current_command - set --erase --global _sponge_current_command_exit_code - set --erase --global _sponge_current_command_previously_in_history -end diff --git a/fish/functions/_sponge_on_exit.fish b/fish/functions/_sponge_on_exit.fish deleted file mode 100644 index 0c6cc19..0000000 --- a/fish/functions/_sponge_on_exit.fish +++ /dev/null @@ -1,3 +0,0 @@ -function _sponge_on_exit --on-event fish_exit - sponge_delay=0 _sponge_remove_from_history -end diff --git a/fish/functions/_sponge_on_postexec.fish b/fish/functions/_sponge_on_postexec.fish deleted file mode 100644 index 1d67935..0000000 --- a/fish/functions/_sponge_on_postexec.fish +++ /dev/null @@ -1,24 +0,0 @@ -function _sponge_on_postexec --on-event fish_postexec - set --global _sponge_current_command_exit_code $status - - # Remove command from the queue if it's been added previously - if set --local index (contains --index -- $_sponge_current_command $_sponge_queue) - set --erase _sponge_queue[$index] - end - - # Ignore empty commands - if test -n $_sponge_current_command - set --local command '' - # Run filters - for filter in $sponge_filters - if $filter \ - $_sponge_current_command \ - $_sponge_current_command_exit_code \ - $_sponge_current_command_previously_in_history - set command $_sponge_current_command - break - end - end - set --prepend --global _sponge_queue $command - end -end diff --git a/fish/functions/_sponge_on_preexec.fish b/fish/functions/_sponge_on_preexec.fish deleted file mode 100644 index a866491..0000000 --- a/fish/functions/_sponge_on_preexec.fish +++ /dev/null @@ -1,16 +0,0 @@ -function _sponge_on_preexec --on-event fish_preexec \ - --argument-names command - _sponge_clear_state - - set --global _sponge_current_command $command - - builtin history search --case-sensitive --exact --max=1 --null $command \ - | read --local --null found_entries - - # If a command is in the history and in the queue, ignore it, like if it wasn’t in the history - if test (count $found_entries) -ne 0; and not contains $command $_sponge_queue - set --global _sponge_current_command_previously_in_history true - else - set --global _sponge_current_command_previously_in_history false - end -end diff --git a/fish/functions/_sponge_on_prompt.fish b/fish/functions/_sponge_on_prompt.fish deleted file mode 100644 index 03e989a..0000000 --- a/fish/functions/_sponge_on_prompt.fish +++ /dev/null @@ -1,5 +0,0 @@ -function _sponge_on_prompt --on-event fish_prompt - if test $sponge_purge_only_on_exit = false - _sponge_remove_from_history - end -end diff --git a/fish/functions/_sponge_remove_from_history.fish b/fish/functions/_sponge_remove_from_history.fish deleted file mode 100644 index 4d4f827..0000000 --- a/fish/functions/_sponge_remove_from_history.fish +++ /dev/null @@ -1,9 +0,0 @@ -function _sponge_remove_from_history - - while test (count $_sponge_queue) -gt $sponge_delay - builtin history delete --case-sensitive --exact -- $_sponge_queue[-1] - set --erase _sponge_queue[-1] - end - - builtin history save -end diff --git a/fish/functions/sponge_filter_failed.fish b/fish/functions/sponge_filter_failed.fish deleted file mode 100644 index be26e5d..0000000 --- a/fish/functions/sponge_filter_failed.fish +++ /dev/null @@ -1,11 +0,0 @@ -function sponge_filter_failed \ - --argument-names command exit_code previously_in_history - - if test $previously_in_history = true -a $sponge_allow_previously_successful = true - return 1 - end - - if contains $exit_code $sponge_successful_exit_codes - return 1 - end -end diff --git a/fish/functions/sponge_filter_matched.fish b/fish/functions/sponge_filter_matched.fish deleted file mode 100644 index c3c7ea2..0000000 --- a/fish/functions/sponge_filter_matched.fish +++ /dev/null @@ -1,11 +0,0 @@ -function sponge_filter_matched \ - --argument-names command - - for pattern in $sponge_regex_patterns - if string match --regex --quiet $pattern -- $command - return - end - end - - return 1 -end