diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-10-14 19:31:39 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-10-14 19:31:39 +0800 |
| commit | 7354e9bb9223039ab5a6626cdaffc6bf70b3f0ce (patch) | |
| tree | 2a5298e4b79802dcd24fb39512b84c55bd215fbf /dot-config/fish | |
| parent | 9aa94c47bc48f3fac9651f4b34a5990e3e5bd02b (diff) | |
bump: fish
Diffstat (limited to 'dot-config/fish')
| -rw-r--r-- | dot-config/fish/conf.d/__zoxide.fish | 1 | ||||
| -rw-r--r-- | dot-config/fish/conf.d/abbr.fish | 27 | ||||
| -rw-r--r-- | dot-config/fish/conf.d/env.fish | 1 | ||||
| -rw-r--r-- | dot-config/fish/conf.d/git.abbr.fish | 35 | ||||
| -rw-r--r-- | dot-config/fish/conf.d/z.fish | 63 | ||||
| -rw-r--r-- | dot-config/fish/fish_plugins | 1 | ||||
| -rw-r--r-- | dot-config/fish/fish_variables | 6 | ||||
| -rw-r--r-- | dot-config/fish/functions/__z.fish | 177 | ||||
| -rw-r--r-- | dot-config/fish/functions/__z_add.fish | 49 | ||||
| -rw-r--r-- | dot-config/fish/functions/__z_clean.fish | 11 | ||||
| -rw-r--r-- | dot-config/fish/functions/__z_complete.fish | 13 |
11 files changed, 29 insertions, 355 deletions
diff --git a/dot-config/fish/conf.d/__zoxide.fish b/dot-config/fish/conf.d/__zoxide.fish new file mode 100644 index 00000000..2e9cc179 --- /dev/null +++ b/dot-config/fish/conf.d/__zoxide.fish @@ -0,0 +1 @@ +zoxide init fish | source diff --git a/dot-config/fish/conf.d/abbr.fish b/dot-config/fish/conf.d/abbr.fish index 3d1cf214..883d3629 100644 --- a/dot-config/fish/conf.d/abbr.fish +++ b/dot-config/fish/conf.d/abbr.fish @@ -6,8 +6,8 @@ abbr -a nmap "sudo nmap" abbr -a update-grub "sudo update-grub" abbr -a mtar "tar -zcvf" abbr -a utar "tar -zxvf" -abbr -a z "zip -r" -abbr -a uz unzip +# abbr -a z "zip -r" +# abbr -a uz unzip # alias unzip='ouch d' # alias compress='ouch c' # alias zip='ouch c' @@ -16,15 +16,15 @@ abbr -a compress zip abbr -a sr "source ~/.config/zsh/env.zsh" abbr -a .. "cd .." abbr -a psg "ps aux | grep -v grep | grep -i -e VSZ -e" -abbr -a mkdir "mkdir -p" +alias mkdir "mkdir -p" abbr -a fm ranger abbr -a cat "bat --plain --pager=never" # alias grep='grep --color=auto' -abbr -a grep "rg --no-heading --with-filename --smart-case -F" -abbr -a mv "mv -v" -abbr -a cp "cp --reflink=auto -vr" -abbr -a rm "trash -v" +alias grep "rg --no-heading --with-filename --smart-case -F" +alias mv "mv -v" +alias cp "cp --reflink=auto -vr" +alias rm "trash -v" abbr -a gpt sgpt abbr -a chat gpt @@ -83,8 +83,8 @@ abbr -a web2app "nativefier --name " #alias vim='/home/system/scripts/vim' #alias vim='lvim' # copy/paste from terminal -abbr -a copy wl-copy -abbr -a paste wl-paste +alias copy wl-copy +alias paste wl-paste # port forwarding & webserver abbr -a cloudflarepf "cloudflared tunnel --url localhost:" abbr -a portforward "cloudflared tunnel --url localhost:" @@ -242,11 +242,6 @@ abbr -a frep "grep -ir" # vim:ft=zsh # doesn't work in zshenv -# idk Y but it will say no correct -abbr -a j "nocorrect j" -abbr -a killall "nocorrect killall" -abbr -a mysql mysql - # alias sys='nu -c sys' abbr -a usys "systemctl --user" abbr -a sysu "systemctl --user" @@ -346,6 +341,6 @@ end abbr -a icat "kitten icat" -abbr -a mkcd "nocorrect mkcd" - abbr -a cd z + +abbr -a md mkdir diff --git a/dot-config/fish/conf.d/env.fish b/dot-config/fish/conf.d/env.fish index e6d4b973..fbc3e699 100644 --- a/dot-config/fish/conf.d/env.fish +++ b/dot-config/fish/conf.d/env.fish @@ -41,7 +41,6 @@ set -x XDG_DATA_HOME "$HOME/.local/share" set -x XDG_STATE_HOME "$HOME/.local/state" set -x XDG_CONFIG_DIRS /etc/xdg set -x XDG_DATA_DIRS "/usr/local/share:/usr/share:/var/lib/flatpak/exports/share:$XDG_DATA_HOME/flatpak/exports/share" -set -x XDG_RUNTIME_DIR "/run/user/(id -u)" set -x XDG_DESKTOP_DIR "$HOME/Desktop" set -x XDG_DOWNLOAD_DIR "$HOME/Downloads" set -x XDG_TEMPLATES_DIR "$HOME/Templates" diff --git a/dot-config/fish/conf.d/git.abbr.fish b/dot-config/fish/conf.d/git.abbr.fish index 5a37d812..c267e7d4 100644 --- a/dot-config/fish/conf.d/git.abbr.fish +++ b/dot-config/fish/conf.d/git.abbr.fish @@ -1,4 +1,3 @@ - #!/bin/bash set -x LOG_HASH "%C(always,yellow)%h%C(always,reset)" @@ -37,16 +36,16 @@ end function pretty_git_format sed -Ee 's/(^[^)]*) ago\)/\1)/' \ - | sed -Ee 's/(^[^)]*), [[:digit:]]+ .*months?\)/\1)/' \ - | sed -Ee 's/ seconds?\)/s\)/' \ - | sed -Ee 's/ minutes?\)/m\)/' \ - | sed -Ee 's/ hours?\)/h\)/' \ - | sed -Ee 's/ days?\)/d\)/' \ - | sed -Ee 's/ weeks?\)/w\)/' \ - | sed -Ee 's/ months?\)/M\)/' \ - | sed -Ee 's/<Andrew Burgess>/<me>/' \ - | sed -Ee 's/<([^ >]+) [^>]*>/<\1>/' \ - | column -s '}' -t + | sed -Ee 's/(^[^)]*), [[:digit:]]+ .*months?\)/\1)/' \ + | sed -Ee 's/ seconds?\)/s\)/' \ + | sed -Ee 's/ minutes?\)/m\)/' \ + | sed -Ee 's/ hours?\)/h\)/' \ + | sed -Ee 's/ days?\)/d\)/' \ + | sed -Ee 's/ weeks?\)/w\)/' \ + | sed -Ee 's/ months?\)/M\)/' \ + | sed -Ee 's/<Andrew Burgess>/<me>/' \ + | sed -Ee 's/<([^ >]+) [^>]*>/<\1>/' \ + | column -s '}' -t end #alias tree='tree -a -I .git' @@ -229,7 +228,7 @@ abbr -a gr "git remote" # alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' # alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"' # alias gcl='git clone --recurse-submodules' -abbr -a gl "git log --decorate --graph" +alias gl "git log --decorate --graph" function gcl git clone --recurse-submodules $argv; or gh repo clone $argv -- --recurse-submodules end @@ -237,15 +236,15 @@ end # alias gl='git log' #alias ga='git add' # alias gc='git commit -am' -abbr -a gc "git commit --verbose -S -m" -abbr -a gcnm 'git commit --verbose --allow-empty-message -S -m ""' -abbr -a gca "git commit --verbose -S -am" +alias gc "git commit --verbose -S -m" +alias gcnm 'git commit --verbose --allow-empty-message -S -m ""' +alias gca "git commit --verbose -S -am" # alias gp='git push origin main' # alias gp='git remote | xargs -L1 git push --all' # moved to funcs -abbr -a gp 'git remote | xargs -L1 git push' -abbr -a gpd 'git remote | xargs -L1 git push --delete' +alias gp 'git remote | xargs -L1 git push' +alias gpd 'git remote | xargs -L1 git push --delete' # alias gpf='git push --force-with-lease' -abbr -a gitp 'git remote | xargs -L1 git pull' +alias gitp 'git remote | xargs -L1 git pull' abbr -a gs "git status" abbr -a gitrm "git rm --cached -rf" # alias gsb='git switch' diff --git a/dot-config/fish/conf.d/z.fish b/dot-config/fish/conf.d/z.fish deleted file mode 100644 index 59c960fc..00000000 --- a/dot-config/fish/conf.d/z.fish +++ /dev/null @@ -1,63 +0,0 @@ -if test -z "$Z_DATA" - if test -z "$XDG_DATA_HOME" - set -U Z_DATA_DIR "$HOME/.local/share/z" - else - set -U Z_DATA_DIR "$XDG_DATA_HOME/z" - end - set -U Z_DATA "$Z_DATA_DIR/data" -end - -if test ! -e "$Z_DATA" - if test ! -e "$Z_DATA_DIR" - mkdir -p -m 700 "$Z_DATA_DIR" - end - touch "$Z_DATA" -end - -if test -z "$Z_CMD" - set -U Z_CMD z -end - -set -U ZO_CMD "$Z_CMD"o - -if test ! -z $Z_CMD - function $Z_CMD -d "jump around" - __z $argv - end -end - -if test ! -z $ZO_CMD - function $ZO_CMD -d "open target dir" - __z -d $argv - end -end - -if not set -q Z_EXCLUDE - set -U Z_EXCLUDE "^$HOME\$" -else if contains $HOME $Z_EXCLUDE - # Workaround: migrate old default values to a regex (see #90). - set Z_EXCLUDE (string replace -r -- "^$HOME\$" '^'$HOME'$$' $Z_EXCLUDE) -end - -# Setup completions once first -__z_complete - -function __z_on_variable_pwd --on-variable PWD - __z_add -end - -function __z_uninstall --on-event z_uninstall - functions -e __z_on_variable_pwd - functions -e $Z_CMD - functions -e $ZO_CMD - - if test ! -z "$Z_DATA" - printf "To completely erase z's data, remove:\n" >/dev/stderr - printf "%s\n" "$Z_DATA" >/dev/stderr - end - - set -e Z_CMD - set -e ZO_CMD - set -e Z_DATA - set -e Z_EXCLUDE -end diff --git a/dot-config/fish/fish_plugins b/dot-config/fish/fish_plugins deleted file mode 100644 index 6ff412d7..00000000 --- a/dot-config/fish/fish_plugins +++ /dev/null @@ -1 +0,0 @@ -/mnt/DATA/personal/Code/projects/z diff --git a/dot-config/fish/fish_variables b/dot-config/fish/fish_variables index b108f2e1..9250db64 100644 --- a/dot-config/fish/fish_variables +++ b/dot-config/fish/fish_variables @@ -1,13 +1,7 @@ # This file contains fish universal variable definitions. # VERSION: 3.0 -SETUVAR ZO_CMD:zo -SETUVAR Z_CMD:z -SETUVAR Z_DATA:/home/system/\x2elocal/share/z/data SETUVAR Z_DATA_DIR:/home/system/\x2elocal/share/z -SETUVAR Z_EXCLUDE:\x5e/home/system\x24 SETUVAR __fish_initialized:3800 -SETUVAR _fisher__2F_mnt_2F_44_41_TA_2F_personal_2F_43_ode_2F_projects_2F_z_files:\x7e/\x2econfig/fish/functions/__z\x2efish\x1e\x7e/\x2econfig/fish/functions/__z_add\x2efish\x1e\x7e/\x2econfig/fish/functions/__z_clean\x2efish\x1e\x7e/\x2econfig/fish/functions/__z_complete\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/z\x2efish -SETUVAR _fisher_plugins:/mnt/DATA/personal/Code/projects/z SETUVAR _fisher_upgraded_to_4_4:\x1d SETUVAR fish_color_autosuggestion:brblack SETUVAR fish_color_cancel:\x2dr diff --git a/dot-config/fish/functions/__z.fish b/dot-config/fish/functions/__z.fish deleted file mode 100644 index 8043f8f3..00000000 --- a/dot-config/fish/functions/__z.fish +++ /dev/null @@ -1,177 +0,0 @@ -function __z -d "Jump to a recent directory." - function __print_help -d "Print z help." - printf "Usage: $Z_CMD [-celrth] string1 string2...\n\n" - printf " -c --clean Removes directories that no longer exist from $Z_DATA\n" - printf " -d --dir Opens matching directory using system file manager.\n" - printf " -e --echo Prints best match, no cd\n" - printf " -l --list List matches and scores, no cd\n" - printf " -p --purge Delete all entries from $Z_DATA\n" - printf " -r --rank Search by rank\n" - printf " -t --recent Search by recency\n" - printf " -x --delete Removes the current directory from $Z_DATA\n" - printf " -h --help Print this help\n\n" - end - function __z_legacy_escape_regex - # taken from escape_string_pcre2 in fish - # used to provide compatibility with fish 2 - for c in (string split -- '' $argv) - if contains $c (string split '' '.^$*+()?[{}\\|-]') - printf \\ - end - printf '%s' $c - end - end - - set -l options h/help c/clean e/echo l/list p/purge r/rank t/recent d/directory x/delete - - argparse $options -- $argv - - if set -q _flag_help - __print_help - return 0 - else if set -q _flag_clean - __z_clean - printf "%s cleaned!\n" $Z_DATA - return 0 - else if set -q _flag_purge - echo >$Z_DATA - printf "%s purged!\n" $Z_DATA - return 0 - else if set -q _flag_delete - sed -i -e "\:^$PWD|.*:d" $Z_DATA - return 0 - end - - set -l typ - - if set -q _flag_rank - set typ rank - else if set -q _flag_recent - set typ recent - end - - set -l z_script ' - function frecent(rank, time) { - dx = t-time - if( dx < 3600 ) return rank*4 - if( dx < 86400 ) return rank*2 - if( dx < 604800 ) return rank/2 - return rank/4 - } - - function output(matches, best_match, common) { - # list or return the desired directory - if( list ) { - cmd = "sort -nr" - for( x in matches ) { - if( matches[x] ) { - printf "%-10s %s\n", matches[x], x | cmd - } - } - } else { - if( common ) best_match = common - print best_match - } - } - - function common(matches) { - # find the common root of a list of matches, if it exists - for( x in matches ) { - if( matches[x] && (!short || length(x) < length(short)) ) { - short = x - } - } - if( short == "/" ) return - for( x in matches ) if( matches[x] && index(x, short) != 1 ) { - return - } - return short - } - - BEGIN { - hi_rank = ihi_rank = -9999999999 - } - { - if( typ == "rank" ) { - rank = $2 - } else if( typ == "recent" ) { - rank = $3 - t - } else rank = frecent($2, $3) - if( $1 ~ q ) { - matches[$1] = rank - } else if( tolower($1) ~ tolower(q) ) imatches[$1] = rank - if( matches[$1] && matches[$1] > hi_rank ) { - best_match = $1 - hi_rank = matches[$1] - } else if( imatches[$1] && imatches[$1] > ihi_rank ) { - ibest_match = $1 - ihi_rank = imatches[$1] - } - } - - END { - # prefer case sensitive - if( best_match ) { - output(matches, best_match, common(matches)) - } else if( ibest_match ) { - output(imatches, ibest_match, common(imatches)) - } - } - ' - - set -l qs - for arg in $argv - set -l escaped $arg - if string escape --style=regex '' >/dev/null 2>&1 # use builtin escape if available - set escaped (string escape --style=regex -- $escaped) - else - set escaped (__z_legacy_escape_regex $escaped) - end - # Need to escape twice, see https://www.math.utah.edu/docs/info/gawk_5.html#SEC32 - set escaped (string replace --all -- \\ \\\\ $escaped) - set qs $qs $escaped - end - set -l q (string join -- '.*' $qs) - - if set -q _flag_list - # Handle list separately as it can print common path information to stderr - # which cannot be captured from a subcommand. - command awk -v t=(date +%s) -v list="list" -v typ="$typ" -v q="$q" -F "|" $z_script "$Z_DATA" - return - end - - if set -q q[1] - set target (command awk -v t=(date +%s) -v typ="$typ" -v q="$q" -F "|" $z_script "$Z_DATA") - else - set target $HOME - end - if test "$status" -gt 0 - return - end - - if test -z "$target" - printf "'%s' did not match any results\n" "$argv" - return 1 - end - - if set -q _flag_echo - printf "%s\n" "$target" - else if set -q _flag_directory - if test -n "$ZO_METHOD" - type -q "$ZO_METHOD"; and "$ZO_METHOD" "$target"; and return $status - echo "Cannot open with ZO_METHOD set to $ZO_METHOD"; and return 1 - else if test "$OS" = Windows_NT - # Be careful, in msys2, explorer always return 1 - type -q explorer; and explorer "$target" - return 0 - echo "Cannot open file explorer" - return 1 - else - type -q xdg-open; and xdg-open "$target"; and return $status - type -q open; and open "$target"; and return $status - echo "Not sure how to open file manager"; and return 1 - end - else - pushd "$target" - end -end diff --git a/dot-config/fish/functions/__z_add.fish b/dot-config/fish/functions/__z_add.fish deleted file mode 100644 index 20d5d7e5..00000000 --- a/dot-config/fish/functions/__z_add.fish +++ /dev/null @@ -1,49 +0,0 @@ -function __z_add -d "Add PATH to .z file" - test -n "$fish_private_mode"; and return 0 - - for i in $Z_EXCLUDE - if string match -r $i $PWD >/dev/null - return 0 #Path excluded - end - end - - set -l tmpfile (mktemp $Z_DATA.XXXXXX) - - if test -f $tmpfile - set -l path (string replace --all \\ \\\\ $PWD) - command awk -v path=$path -v now=(date +%s) -F "|" ' - BEGIN { - rank[path] = 1 - time[path] = now - } - $2 >= 1 { - if( $1 == path ) { - rank[$1] = $2 + 1 - time[$1] = now - } - else { - rank[$1] = $2 - time[$1] = $3 - } - count += $2 - } - END { - if( count > 1000 ) { - for( i in rank ) print i "|" 0.9*rank[i] "|" time[i] # aging - } - else for( i in rank ) print i "|" rank[i] "|" time[i] - } - ' $Z_DATA 2>/dev/null >$tmpfile - - if test ! -z "$Z_OWNER" - chown $Z_OWNER:(id -ng $Z_OWNER) $tmpfile - end - # - # Don't use redirection here as it can lead to a race condition where $Z_DATA is clobbered. - # Note: There is a still a possible race condition where an old version of $Z_DATA is - # read by one instance of Fish before another instance of Fish writes its copy. - # - command mv $tmpfile $Z_DATA - or command rm $tmpfile - end -end diff --git a/dot-config/fish/functions/__z_clean.fish b/dot-config/fish/functions/__z_clean.fish deleted file mode 100644 index ae1721a0..00000000 --- a/dot-config/fish/functions/__z_clean.fish +++ /dev/null @@ -1,11 +0,0 @@ -function __z_clean -d "Clean up .z file to remove paths no longer valid" - set -l tmpfile (mktemp $Z_DATA.XXXXXX) - - if test -f $tmpfile - while read line - set -l path (string split '|' $line)[1] - test -d $path; and echo $line - end <$Z_DATA >$tmpfile - command mv -f $tmpfile $Z_DATA - end -end diff --git a/dot-config/fish/functions/__z_complete.fish b/dot-config/fish/functions/__z_complete.fish deleted file mode 100644 index a6264561..00000000 --- a/dot-config/fish/functions/__z_complete.fish +++ /dev/null @@ -1,13 +0,0 @@ -function __z_complete -d "add completions" - complete -c $Z_CMD -a "(__z -l | string replace -r '^\\S*\\s*' '')" -f -k - complete -c $ZO_CMD -a "(__z -l | string replace -r '^\\S*\\s*' '')" -f -k - - complete -c $Z_CMD -s c -l clean -d "Cleans out $Z_DATA" - complete -c $Z_CMD -s e -l echo -d "Prints best match, no cd" - complete -c $Z_CMD -s l -l list -d "List matches, no cd" - complete -c $Z_CMD -s p -l purge -d "Purges $Z_DATA" - complete -c $Z_CMD -s r -l rank -d "Searches by rank, cd" - complete -c $Z_CMD -s t -l recent -d "Searches by recency, cd" - complete -c $Z_CMD -s h -l help -d "Print help" - complete -c $Z_CMD -s x -l delete -d "Removes the current directory from $Z_DATA" -end |
