mirror of
https://github.com/kogakure/dotfiles.git
synced 2026-02-04 04:35:29 +00:00
chore(fish): add new fisher plugin
This commit is contained in:
@@ -6,5 +6,5 @@ function __abbr_tips_bind_newline
|
||||
set -g __abbr_tips_used 0
|
||||
end
|
||||
end
|
||||
commandline -f 'execute'
|
||||
commandline -f execute
|
||||
end
|
||||
|
||||
@@ -7,5 +7,5 @@ function __abbr_tips_bind_space
|
||||
set -g __abbr_tips_used 0
|
||||
end
|
||||
end
|
||||
commandline -f 'expand-abbr'
|
||||
commandline -f expand-abbr
|
||||
end
|
||||
|
||||
16
fish/functions/__abbr_tips_clean.fish
Normal file
16
fish/functions/__abbr_tips_clean.fish
Normal file
@@ -0,0 +1,16 @@
|
||||
function __abbr_tips_clean -d "Clean plugin variables and functions"
|
||||
bind --erase \n
|
||||
bind --erase \r
|
||||
bind --erase " "
|
||||
set --erase __abbr_tips_used
|
||||
set --erase __abbr_tips_run_once
|
||||
set --erase __ABBR_TIPS_VALUES
|
||||
set --erase __ABBR_TIPS_KEYS
|
||||
set --erase ABBR_TIPS_PROMPT
|
||||
set --erase ABBR_TIPS_AUTO_UPDATE
|
||||
set --erase ABBR_TIPS_ALIAS_WHITELIST
|
||||
set --erase ABBR_TIPS_REGEXES
|
||||
functions --erase __abbr_tips_bind_newline
|
||||
functions --erase __abbr_tips_bind_space
|
||||
functions --erase __abbr_tips
|
||||
end
|
||||
5
fish/functions/_sponge_clear_state.fish
Normal file
5
fish/functions/_sponge_clear_state.fish
Normal file
@@ -0,0 +1,5 @@
|
||||
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
|
||||
3
fish/functions/_sponge_on_exit.fish
Normal file
3
fish/functions/_sponge_on_exit.fish
Normal file
@@ -0,0 +1,3 @@
|
||||
function _sponge_on_exit --on-event fish_exit
|
||||
sponge_delay=0 _sponge_remove_from_history
|
||||
end
|
||||
24
fish/functions/_sponge_on_postexec.fish
Normal file
24
fish/functions/_sponge_on_postexec.fish
Normal file
@@ -0,0 +1,24 @@
|
||||
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
|
||||
16
fish/functions/_sponge_on_preexec.fish
Normal file
16
fish/functions/_sponge_on_preexec.fish
Normal file
@@ -0,0 +1,16 @@
|
||||
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
|
||||
5
fish/functions/_sponge_on_prompt.fish
Normal file
5
fish/functions/_sponge_on_prompt.fish
Normal file
@@ -0,0 +1,5 @@
|
||||
function _sponge_on_prompt --on-event fish_prompt
|
||||
if test $sponge_purge_only_on_exit = false
|
||||
_sponge_remove_from_history
|
||||
end
|
||||
end
|
||||
9
fish/functions/_sponge_remove_from_history.fish
Normal file
9
fish/functions/_sponge_remove_from_history.fish
Normal file
@@ -0,0 +1,9 @@
|
||||
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
|
||||
11
fish/functions/sponge_filter_failed.fish
Normal file
11
fish/functions/sponge_filter_failed.fish
Normal file
@@ -0,0 +1,11 @@
|
||||
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
|
||||
11
fish/functions/sponge_filter_matched.fish
Normal file
11
fish/functions/sponge_filter_matched.fish
Normal file
@@ -0,0 +1,11 @@
|
||||
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
|
||||
Reference in New Issue
Block a user