added fish config

This commit is contained in:
2025-07-30 11:46:46 +02:00
parent 44b40bc8e7
commit 7850c7bb0e
34 changed files with 765 additions and 8 deletions

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 delete-char
commandline --function complete
end

View File

@@ -0,0 +1,3 @@
function batdiff --description 'batdiff function'
git diff --name-only --diff-filter=d $argv | bat --diff
end

3
fish/functions/cat.fish Normal file
View File

@@ -0,0 +1,3 @@
function cat --wraps=bat --description 'alias cat=bat'
bat $argv;
end

3
fish/functions/cpr.fish Normal file
View File

@@ -0,0 +1,3 @@
function cpr
rsync --archive -hh --partial --info=stats1,progress2 --modify-window=1 $argv
end

3
fish/functions/du.fish Normal file
View File

@@ -0,0 +1,3 @@
function du --wraps='dust -bs' --description 'alias du=dust -bs'
dust -bs $argv;
end

View File

@@ -0,0 +1,3 @@
function egrep --description 'alias egrep=egrep --color=auto'
command egrep --color=auto $argv;
end

View File

@@ -0,0 +1,3 @@
function fgrep --description 'alias fgrep=fgrep --color=auto'
command fgrep --color=auto $argv;
end

View File

@@ -0,0 +1,30 @@
function fish_prompt --description 'Write out the prompt'
set -l last_status $status
set -l normal (set_color normal)
set -l status_color (set_color brgreen)
set -l cwd_color (set_color $fish_color_cwd)
set -l vcs_color (set_color brpurple)
set -l prompt_status ""
# Since we display the prompt on a new line allow the directory names to be longer.
set -q fish_prompt_pwd_dir_length
or set -lx fish_prompt_pwd_dir_length 0
# Color the prompt differently when we're root
set -l suffix ''
if functions -q fish_is_root_user; and fish_is_root_user
if set -q fish_color_cwd_root
set cwd_color (set_color $fish_color_cwd_root)
end
set suffix '#'
end
# Color the prompt in red on error
if test $last_status -ne 0
set status_color (set_color $fish_color_error)
set prompt_status $status_color "[" $last_status "]" $normal
end
echo -s (prompt_login) ' ' $cwd_color (prompt_pwd) $vcs_color (fish_vcs_prompt) $normal ' ' $prompt_status
echo -n -s $status_color $suffix ' ' $normal
end

3
fish/functions/grep.fish Normal file
View File

@@ -0,0 +1,3 @@
function grep --description 'alias grep=grep --color=auto'
command grep --color=auto $argv;
end

3
fish/functions/la.fish Normal file
View File

@@ -0,0 +1,3 @@
function la --wraps='exa -a --long --color=auto' --description 'alias la=exa -a --long --color=auto'
exa -a --long --color=auto $argv;
end

3
fish/functions/lg.fish Normal file
View File

@@ -0,0 +1,3 @@
function lg --wraps='exa --git --long' --description 'alias lg=exa --git --long'
exa --git --long $argv;
end

3
fish/functions/ll.fish Normal file
View File

@@ -0,0 +1,3 @@
function ll --wraps='exa --long --color=auto' --description 'alias ll exa --long --color=auto'
exa --long --color=auto $argv;
end

3
fish/functions/ls.fish Normal file
View File

@@ -0,0 +1,3 @@
function ls --wraps='exa --long --color=auto' --description 'alias ls=exa --long --color=auto'
exa --long --color=auto $argv;
end

3
fish/functions/mvr.fish Normal file
View File

@@ -0,0 +1,3 @@
function mvr
rsync --archive -hh --partial --info=stats1,progress2 --modify-window=1 --remove-source-files $argv
end

3
fish/functions/open.fish Normal file
View File

@@ -0,0 +1,3 @@
function open -d "Open an application detached from the terminal"
nohup $argv >/dev/null 2>&1 &
end