Some added thingies

This commit is contained in:
~erin 2023-03-16 14:01:03 -04:00
parent 022ecb4a90
commit f4e6d9a8c5
Signed by: erin
GPG Key ID: 9A8E308CEFA37A47
22 changed files with 340 additions and 1 deletions

39
conf.d/autopair.fish Normal file
View File

@ -0,0 +1,39 @@
status is-interactive || exit
set --global autopair_left "(" "[" "{" '"' "'"
set --global autopair_right ")" "]" "}" '"' "'"
set --global autopair_pairs "()" "[]" "{}" '""' "''"
function _autopair_fish_key_bindings --on-variable fish_key_bindings
set --query fish_key_bindings[1] || return
test $fish_key_bindings = fish_default_key_bindings &&
set --local mode default insert ||
set --local mode insert default
bind --mode $mode[-1] --erase \177 \b \t
bind --mode $mode[1] \177 _autopair_backspace # macOS ⌫
bind --mode $mode[1] \b _autopair_backspace
bind --mode $mode[1] \t _autopair_tab
printf "%s\n" $autopair_pairs | while read --local left right --delimiter ""
bind --mode $mode[-1] --erase $left $right
if test $left = $right
bind --mode $mode[1] $left "_autopair_insert_same \\$left"
else
bind --mode $mode[1] $left "_autopair_insert_left \\$left \\$right"
bind --mode $mode[1] $right "_autopair_insert_right \\$right"
end
end
end
_autopair_fish_key_bindings
function _autopair_uninstall --on-event autopair_uninstall
string collect (
bind --all | string replace --filter --regex -- "_autopair.*" --erase
set --names | string replace --filter --regex -- "^autopair" "set --erase autopair"
) | source
functions --erase (functions --all | string match "_autopair_*")
end

52
conf.d/sponge.fish Normal file
View File

@ -0,0 +1,52 @@
# 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

View File

@ -27,4 +27,7 @@ if status is-interactive
eval "$(zellij setup --generate-auto-start fish)"
zoxide init fish | source
starship init fish | source
# fzf bindings
fzf_configure_bindings
end

View File

@ -1,2 +1,5 @@
jorgebucaran/fisher
patrickf1/fzf.fish
meaningful-ooo/sponge
jorgebucaran/autopair.fish
catppuccin/fish

View File

@ -1,9 +1,12 @@
# This file contains fish universal variable definitions.
# VERSION: 3.0
SETUVAR __fish_initialized:3400
SETUVAR _fisher_catppuccin_2F_fish_files:\x7e/\x2econfig/fish/themes/Catppuccin\x20Frappe\x2etheme\x1e\x7e/\x2econfig/fish/themes/Catppuccin\x20Latte\x2etheme\x1e\x7e/\x2econfig/fish/themes/Catppuccin\x20Macchiato\x2etheme\x1e\x7e/\x2econfig/fish/themes/Catppuccin\x20Mocha\x2etheme
SETUVAR _fisher_jorgebucaran_2F_autopair_2E_fish_files:\x7e/\x2econfig/fish/functions/_autopair_backspace\x2efish\x1e\x7e/\x2econfig/fish/functions/_autopair_insert_left\x2efish\x1e\x7e/\x2econfig/fish/functions/_autopair_insert_right\x2efish\x1e\x7e/\x2econfig/fish/functions/_autopair_insert_same\x2efish\x1e\x7e/\x2econfig/fish/functions/_autopair_tab\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/autopair\x2efish
SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish
SETUVAR _fisher_meaningful_2D_ooo_2F_sponge_files:\x7e/\x2econfig/fish/functions/_sponge_clear_state\x2efish\x1e\x7e/\x2econfig/fish/functions/_sponge_on_exit\x2efish\x1e\x7e/\x2econfig/fish/functions/_sponge_on_postexec\x2efish\x1e\x7e/\x2econfig/fish/functions/_sponge_on_preexec\x2efish\x1e\x7e/\x2econfig/fish/functions/_sponge_on_prompt\x2efish\x1e\x7e/\x2econfig/fish/functions/_sponge_remove_from_history\x2efish\x1e\x7e/\x2econfig/fish/functions/sponge_filter_failed\x2efish\x1e\x7e/\x2econfig/fish/functions/sponge_filter_matched\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/sponge\x2efish
SETUVAR _fisher_patrickf1_2F_fzf_2E_fish_files:\x7e/\x2econfig/fish/functions/_fzf_configure_bindings_help\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_extract_var_info\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_preview_changed_file\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_preview_file\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_report_diff_type\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_report_file_type\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_directory\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_git_log\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_git_status\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_history\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_processes\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_variables\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_wrapper\x2efish\x1e\x7e/\x2econfig/fish/functions/fzf_configure_bindings\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/fzf\x2efish\x1e\x7e/\x2econfig/fish/completions/fzf_configure_bindings\x2efish
SETUVAR _fisher_plugins:jorgebucaran/fisher\x1epatrickf1/fzf\x2efish
SETUVAR _fisher_plugins:jorgebucaran/fisher\x1epatrickf1/fzf\x2efish\x1emeaningful\x2dooo/sponge\x1ejorgebucaran/autopair\x2efish\x1ecatppuccin/fish
SETUVAR _fisher_upgraded_to_4_4:\x1d
SETUVAR fish_color_autosuggestion:6c7086
SETUVAR fish_color_cancel:f38ba8
@ -44,3 +47,9 @@ SETUVAR fish_pager_color_selected_background:\x1d
SETUVAR fish_pager_color_selected_completion:\x1d
SETUVAR fish_pager_color_selected_description:\x1d
SETUVAR fish_pager_color_selected_prefix:\x1d
SETUVAR sponge_allow_previously_successful:true
SETUVAR sponge_delay:2
SETUVAR sponge_filters:sponge_filter_failed\x1esponge_filter_matched
SETUVAR sponge_purge_only_on_exit:false
SETUVAR sponge_regex_patterns:\x1d
SETUVAR sponge_successful_exit_codes:0

View File

@ -0,0 +1,9 @@
function _autopair_backspace
set --local index (commandline --cursor)
set --local buffer (commandline)
test $index -ge 1 &&
contains -- (string sub --start=$index --length=2 -- "$buffer") $autopair_pairs &&
commandline --function delete-char
commandline --function backward-delete-char
end

View File

@ -0,0 +1,13 @@
function _autopair_insert_left --argument-names left right
set --local buffer (commandline)
set --local before (commandline --cut-at-cursor)
commandline --insert -- $left
switch "$buffer"
case "$before"{," "\*,$autopair_right\*}
set --local index (commandline --cursor)
commandline --insert -- $right
commandline --cursor $index
end
end

View File

@ -0,0 +1,11 @@
function _autopair_insert_right --argument-names key
set --local buffer (commandline)
set --local before (commandline --cut-at-cursor)
switch "$buffer"
case "$before$key"\*
commandline --cursor (math (commandline --cursor) + 1)
case \*
commandline --insert -- $key
end
end

View File

@ -0,0 +1,20 @@
function _autopair_insert_same --argument-names key
set --local buffer (commandline)
set --local index (commandline --cursor)
set --local next (string sub --start=(math $index + 1) --length=1 -- "$buffer")
if test (math (count (string match --all --regex -- "$key" "$buffer")) % 2) = 0
test $key = $next && commandline --cursor (math $index + 1) && return
commandline --insert -- $key
if test $index -lt 1 ||
contains -- (string sub --start=$index --length=1 -- "$buffer") "" " " $autopair_left &&
contains -- $next "" " " $autopair_right
commandline --insert -- $key
commandline --cursor (math $index + 1)
end
else
commandline --insert -- $key
end
end

View File

@ -0,0 +1,7 @@
function _autopair_tab
commandline --paging-mode && down-or-search && return
string match --quiet --regex -- '\$[^\s]*"$' (commandline --current-token) &&
commandline --function end-of-line --function backward-delete-char
commandline --function complete
end

View 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

View File

@ -0,0 +1,3 @@
function _sponge_on_exit --on-event fish_exit
sponge_delay=0 _sponge_remove_from_history
end

View 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

View 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 wasnt 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

View 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

View 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

View 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

View 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

View File

@ -30,6 +30,7 @@ function tools
echo "Fish"
toolprint cyan "Ctrl+Alt+L" "Search git log"
toolprint cyan "Ctrl+R" "Search history"
toolprint cyan "Ctrl+V" "Search variables"
toolprint cyan "z" "Smarter cd"
set_color blue
@ -46,4 +47,5 @@ function tools
toolprint cyan ":sS" "SCP send file"
toolprint cyan ":oS" "Ouch compress"
toolprint cyan "P" "Preview image"
toolprint cyan "z" "Open PDF"
end

View File

@ -0,0 +1,29 @@
# name: 'Catppuccin frappe'
# url: 'https://github.com/catppuccin/fish'
# preferred_background: 303446
fish_color_normal c6d0f5
fish_color_command 8caaee
fish_color_param eebebe
fish_color_keyword e78284
fish_color_quote a6d189
fish_color_redirection f4b8e4
fish_color_end ef9f76
fish_color_comment 838ba7
fish_color_error e78284
fish_color_gray 737994
fish_color_selection --background=414559
fish_color_search_match --background=414559
fish_color_operator f4b8e4
fish_color_escape ea999c
fish_color_autosuggestion 737994
fish_color_cancel e78284
fish_color_cwd e5c890
fish_color_user 81c8be
fish_color_host 8caaee
fish_color_host_remote a6d189
fish_color_status e78284
fish_pager_color_progress 737994
fish_pager_color_prefix f4b8e4
fish_pager_color_completion c6d0f5
fish_pager_color_description 737994

View File

@ -0,0 +1,29 @@
# name: 'Catppuccin latte'
# url: 'https://github.com/catppuccin/fish'
# preferred_background: eff1f5
fish_color_normal 4c4f69
fish_color_command 1e66f5
fish_color_param dd7878
fish_color_keyword d20f39
fish_color_quote 40a02b
fish_color_redirection ea76cb
fish_color_end fe640b
fish_color_comment 8c8fa1
fish_color_error d20f39
fish_color_gray 9ca0b0
fish_color_selection --background=ccd0da
fish_color_search_match --background=ccd0da
fish_color_operator ea76cb
fish_color_escape e64553
fish_color_autosuggestion 9ca0b0
fish_color_cancel d20f39
fish_color_cwd df8e1d
fish_color_user 179299
fish_color_host_remote 40a02b
fish_color_host 1e66f5
fish_color_status d20f39
fish_pager_color_progress 9ca0b0
fish_pager_color_prefix ea76cb
fish_pager_color_completion 4c4f69
fish_pager_color_description 9ca0b0

View File

@ -0,0 +1,29 @@
# name: 'Catppuccin macchiato'
# url: 'https://github.com/catppuccin/fish'
# preferred_background: 24273a
fish_color_normal cad3f5
fish_color_command 8aadf4
fish_color_param f0c6c6
fish_color_keyword ed8796
fish_color_quote a6da95
fish_color_redirection f5bde6
fish_color_end f5a97f
fish_color_comment 8087a2
fish_color_error ed8796
fish_color_gray 6e738d
fish_color_selection --background=363a4f
fish_color_search_match --background=363a4f
fish_color_operator f5bde6
fish_color_escape ee99a0
fish_color_autosuggestion 6e738d
fish_color_cancel ed8796
fish_color_cwd eed49f
fish_color_user 8bd5ca
fish_color_host 8aadf4
fish_color_host_remote a6da95
fish_color_status ed8796
fish_pager_color_progress 6e738d
fish_pager_color_prefix f5bde6
fish_pager_color_completion cad3f5
fish_pager_color_description 6e738d