Update fish

This commit is contained in:
Hydroxycarbamide 2023-04-03 16:40:39 +02:00
parent f5306476ea
commit 123172a72b
16 changed files with 382 additions and 41 deletions

View file

@ -2,13 +2,12 @@ zoxide init fish | source
if status is-interactive
# Commands to run in interactive sessions can go here
# ls
alias l='exa -lh'
alias ls='exa'
alias ll='exa -lah'
alias la='ls -A'
alias lm='ls -m'
alias l='exa -lh --icons'
alias ls='exa --icons'
alias ll='exa -lah --icons'
alias lm='exa -m'
alias lr='exa -R'
alias lg='exa -l --group-directories-first'
alias lg='exa -l --group-directories-first --icons'
alias tree='exa --tree'
# git
@ -29,4 +28,42 @@ if status is-interactive
# emacs
alias emacs='emacsclient -nc -s instance1'
# doas
alias sudo='doas'
# pnpm
alias pn='pnpm'
# paru
alias pa='paru'
alias yay='paru'
# codium wayland
# alias codium='codium --enable-features=UseOzonePlatform --ozone-platform=wayland'
alias codiumwl='codium --enable-features=UseOzonePlatform --ozone-platform=wayland'
alias codewl='code --enable-features=UseOzonePlatform --ozone-platform=wayland'
# systemctl
alias sys='systemctl'
alias sysuser='systemctl --user'
# fancy cp
alias fcp='rsync -avP'
# moar
alias less='moar'
# helix
alias hx='helix'
end
thefuck --alias | source
# >>> mamba initialize >>>
# !! Contents within this block are managed by 'mamba init' !!
set -gx MAMBA_EXE "/usr/bin/micromamba"
set -gx MAMBA_ROOT_PREFIX "/home/eric/micromamba"
$MAMBA_EXE shell hook --shell fish --prefix $MAMBA_ROOT_PREFIX | source
# <<< mamba initialize <<<

35
config.fish.bak Normal file
View file

@ -0,0 +1,35 @@
zoxide init fish | source
if status is-interactive
# Commands to run in interactive sessions can go here
# ls
alias l='exa -lh'
alias ls='exa'
alias ll='exa -lah'
alias la='ls -A'
alias lm='ls -m'
alias lr='exa -R'
alias lg='exa -l --group-directories-first'
alias tree='exa --tree'
# git
alias gcl='git clone --depth 1'
alias gi='git init'
alias ga='git add'
alias gc='git commit -m'
alias gp='git push origin master'
# cat
alias cat='bat -p'
# cd/zoxide
alias cd='z'
# vim
alias vim='nvim'
# emacs
alias emacs='emacsclient -nc -s instance1'
# doas
alias sudo='doas'
end

View file

@ -1,2 +1,3 @@
mattgreen/lucid.fish
PatrickF1/fzf.fish
decors/fish-colored-man
catppuccin/fish

View file

@ -1,36 +1,52 @@
# This file contains fish universal variable definitions.
# VERSION: 3.0
SETUVAR --export FZF_DEFAULT_OPTS:\x2d\x2dcolor\x3dbg\x2b\x3a\x23363a4f\x2cbg\x3a\x2324273a\x2cspinner\x3a\x23f4dbd6\x2chl\x3a\x23ed8796\x20\x2d\x2dcolor\x3dfg\x3a\x23cad3f5\x2cheader\x3a\x23ed8796\x2cinfo\x3a\x23c6a0f6\x2cpointer\x3a\x23f4dbd6\x20\x2d\x2dcolor\x3dmarker\x3a\x23f4dbd6\x2cfg\x2b\x3a\x23cad3f5\x2cprompt\x3a\x23c6a0f6\x2chl\x2b\x3a\x23ed8796
SETUVAR --export PAGER:/usr/local/bin/moar
SETUVAR __fish_initialized:3400
SETUVAR _fisher_PatrickF1_2F_fzf_2E_fish_files:/home/eric/\x2econfig/fish/functions/_fzf_configure_bindings_help\x2efish\x1e/home/eric/\x2econfig/fish/functions/_fzf_extract_var_info\x2efish\x1e/home/eric/\x2econfig/fish/functions/_fzf_preview_file\x2efish\x1e/home/eric/\x2econfig/fish/functions/_fzf_report_file_type\x2efish\x1e/home/eric/\x2econfig/fish/functions/_fzf_search_directory\x2efish\x1e/home/eric/\x2econfig/fish/functions/_fzf_search_git_log\x2efish\x1e/home/eric/\x2econfig/fish/functions/_fzf_search_git_status\x2efish\x1e/home/eric/\x2econfig/fish/functions/_fzf_search_history\x2efish\x1e/home/eric/\x2econfig/fish/functions/_fzf_search_processes\x2efish\x1e/home/eric/\x2econfig/fish/functions/_fzf_search_variables\x2efish\x1e/home/eric/\x2econfig/fish/functions/_fzf_wrapper\x2efish\x1e/home/eric/\x2econfig/fish/functions/fzf_configure_bindings\x2efish\x1e/home/eric/\x2econfig/fish/conf\x2ed/fzf\x2efish\x1e/home/eric/\x2econfig/fish/completions/fzf_configure_bindings\x2efish
SETUVAR _fisher_mattgreen_2F_lucid_2E_fish_files:/home/eric/\x2econfig/fish/functions/fish_prompt\x2efish
SETUVAR _fisher_plugins:mattgreen/lucid\x2efish\x1ePatrickF1/fzf\x2efish
SETUVAR fish_color_autosuggestion:BD93F9
SETUVAR fish_color_cancel:\x2d\x2dreverse
SETUVAR fish_color_command:F8F8F2
SETUVAR fish_color_comment:6272A4
SETUVAR fish_color_cwd:green
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_decors_2F_fish_2D_colored_2D_man_files:\x7e/\x2econfig/fish/functions/man\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:patrickf1/fzf\x2efish\x1edecors/fish\x2dcolored\x2dman\x1ecatppuccin/fish
SETUVAR _fisher_upgraded_to_4_4:\x1d
SETUVAR fish_color_autosuggestion:6e738d
SETUVAR fish_color_cancel:ed8796
SETUVAR fish_color_command:8aadf4
SETUVAR fish_color_comment:\x1d
SETUVAR fish_color_cwd:eed49f
SETUVAR fish_color_cwd_root:red
SETUVAR fish_color_end:50FA7B
SETUVAR fish_color_error:FFB86C
SETUVAR fish_color_escape:00a6b2
SETUVAR fish_color_end:f5a97f
SETUVAR fish_color_error:ed8796
SETUVAR fish_color_escape:f0c6c6
SETUVAR fish_color_gray:6e738d
SETUVAR fish_color_history_current:\x2d\x2dbold
SETUVAR fish_color_host:normal
SETUVAR fish_color_host_remote:yellow
SETUVAR fish_color_host:8aadf4
SETUVAR fish_color_host_remote:\x1d
SETUVAR fish_color_keyword:ed8796
SETUVAR fish_color_match:\x2d\x2dbackground\x3dbrblue
SETUVAR fish_color_normal:normal
SETUVAR fish_color_operator:00a6b2
SETUVAR fish_color_param:FF79C6
SETUVAR fish_color_quote:F1FA8C
SETUVAR fish_color_redirection:8BE9FD
SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack
SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack
SETUVAR fish_color_normal:cad3f5
SETUVAR fish_color_operator:f5bde6
SETUVAR fish_color_option:\x1d
SETUVAR fish_color_param:f0c6c6
SETUVAR fish_color_quote:a6da95
SETUVAR fish_color_redirection:f5bde6
SETUVAR fish_color_search_match:\x2d\x2dbackground\x3d363a4f
SETUVAR fish_color_selection:\x2d\x2dbackground\x3d363a4f
SETUVAR fish_color_status:red
SETUVAR fish_color_user:brgreen
SETUVAR fish_color_user:8bd5ca
SETUVAR fish_color_valid_path:\x2d\x2dunderline
SETUVAR fish_greeting:\x1d
SETUVAR fish_key_bindings:fish_vi_key_bindings
SETUVAR fish_pager_color_completion:normal
SETUVAR fish_pager_color_description:B3A06D
SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
SETUVAR fish_pager_color_selected_background:\x2d\x2dbackground\x3dbrblack
SETUVAR fish_pager_color_background:\x1d
SETUVAR fish_pager_color_completion:cad3f5
SETUVAR fish_pager_color_description:6e738d
SETUVAR fish_pager_color_prefix:f5bde6
SETUVAR fish_pager_color_progress:6e738d
SETUVAR fish_pager_color_secondary_background:\x1d
SETUVAR fish_pager_color_secondary_completion:\x1d
SETUVAR fish_pager_color_secondary_description:\x1d
SETUVAR fish_pager_color_secondary_prefix:\x1d
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 fish_user_paths:/home/eric/\x2ebun/bin\x1e/usr/bin\x1e/usr/sbin\x1e/usr/local/bin\x1e/usr/local/sbin

View file

@ -0,0 +1,30 @@
# helper for _fzf_search_git_status
# arg should be a line from git status --short, e.g.
# MM functions/_fzf_preview_changed_file.fish
# D README.md
# R LICENSE.md -> LICENSE
function _fzf_preview_changed_file --description "Show the untracked, staged, and/or unstaged changes in the given file."
set -l path (string split ' ' $argv)[-1]
# first letter of short format shows index, second letter shows working tree
# https://git-scm.com/docs/git-status/2.35.0#_output
set -l index_status (string sub --length 1 $argv)
set -l working_tree_status (string sub --start 2 --length 1 $argv)
if test $index_status = '?'
_fzf_report_diff_type Untracked
_fzf_preview_file $path
else
# no-prefix because the file is always being compared to itself so is unecessary
set diff_opts --color=always --no-prefix
if test $index_status != ' '
_fzf_report_diff_type Staged
git diff --staged $diff_opts -- $path
end
if test $working_tree_status != ' '
_fzf_report_diff_type Unstaged
git diff $diff_opts -- $path
end
end
end

View file

@ -1,4 +1,4 @@
# helper function for _fzf_search_directory
# helper function for _fzf_search_directory and _fzf_search_git_status
function _fzf_preview_file --description "Print a preview for the given file based on its file type."
# because there's no way to guarantee that _fzf_search_directory passes the path to _fzf_preview_file
# as one argument, we collect all the arguments into one single variable and treat that as the path

View file

@ -0,0 +1,16 @@
# helper for _fzf_preview_changed_file
# prints out something like
# +--------+
# | Staged |
# +--------+
function _fzf_report_diff_type --argument-names diff_type --description "Print a distinct colored header meant to preface a git patch."
# number of "-" to draw is the length of the string to box + 2 for padding
set repeat_count (math 2 + (string length $diff_type))
set horizontal_border +(string repeat --count $repeat_count -)+
set_color yellow
echo $horizontal_border
echo "| $diff_type |"
echo $horizontal_border
set_color normal
end

View file

@ -31,7 +31,8 @@ function _fzf_search_directory --description "Search the current directory. Repl
# Then, the user only needs to hit Enter once more to cd into that directory.
if test (count $file_paths_selected) = 1
set commandline_tokens (commandline --tokenize)
if test "$commandline_tokens" = "$token" -a -d "$file_paths_selected"
if test "$commandline_tokens" = "$token" -a -d "$file_paths_selected" \
-a (fd --version | string replace --regex --all '[^\d]' '') -lt 840
set file_paths_selected $file_paths_selected/
end
end

View file

@ -8,6 +8,7 @@ function _fzf_search_git_status --description "Search the output of git status.
_fzf_wrapper --ansi \
--multi \
--query=(commandline --current-token) \
--preview='_fzf_preview_changed_file {}' \
$fzf_git_status_opts
)
if test $status -eq 0

View file

@ -1,23 +1,29 @@
function _fzf_search_history --description "Search command history. Replace the command line with the selected command."
# history merge incorporates history changes from other fish sessions
builtin history merge
# it errors out if called in private mode
if test -z "$fish_private_mode"
builtin history merge
end
set command_with_ts (
# Delinate commands throughout pipeline using null rather than newlines because commands can be multi-line
set commands_selected (
# Reference https://devhints.io/strftime to understand strftime format symbols
builtin history --null --show-time="%m-%d %H:%M:%S │ " |
_fzf_wrapper --read0 \
--print0 \
--multi \
--tiebreak=index \
--query=(commandline) \
# preview current command using fish_ident in a window at the bottom 3 lines tall
--preview="echo -- {4..} | fish_indent --ansi" \
--preview-window="bottom:3:wrap" \
$fzf_history_opts |
string collect
string split0 |
# remove timestamps from commands selected
string replace --regex '^\d\d-\d\d \d\d:\d\d:\d\d │ ' ''
)
if test $status -eq 0
set command_selected (string split --max 1 " │ " $command_with_ts)[2]
commandline --replace -- $command_selected
commandline --replace -- $commands_selected
end
commandline --function repaint

41
functions/man.fish Normal file
View file

@ -0,0 +1,41 @@
function man --wraps man --description 'Format and display manual pages'
set -q man_blink; and set -l blink (set_color $man_blink); or set -l blink (set_color -o red)
set -q man_bold; and set -l bold (set_color $man_bold); or set -l bold (set_color -o 5fafd7)
set -q man_standout; and set -l standout (set_color $man_standout); or set -l standout (set_color 949494)
set -q man_underline; and set -l underline (set_color $man_underline); or set -l underline (set_color -u afafd7)
set -l end (printf "\e[0m")
set -lx LESS_TERMCAP_mb $blink
set -lx LESS_TERMCAP_md $bold
set -lx LESS_TERMCAP_me $end
set -lx LESS_TERMCAP_so $standout
set -lx LESS_TERMCAP_se $end
set -lx LESS_TERMCAP_us $underline
set -lx LESS_TERMCAP_ue $end
set -lx LESS '-R -s'
set -lx GROFF_NO_SGR yes # fedora
set -lx MANPATH (string join : $MANPATH)
if test -z "$MANPATH"
type -q manpath
and set MANPATH (command manpath)
end
# Check data dir for Fish 2.x compatibility
set -l fish_data_dir
if set -q __fish_data_dir
set fish_data_dir $__fish_data_dir
else
set fish_data_dir $__fish_datadir
end
set -l fish_manpath (dirname $fish_data_dir)/fish/man
if test -d "$fish_manpath" -a -n "$MANPATH"
set MANPATH "$fish_manpath":$MANPATH
command man $argv
return
end
command man $argv
end

53
functions/nvm.fish Normal file
View file

@ -0,0 +1,53 @@
function nvm-fast
set -q NVM_DIR ; or set -l NVM_DIR ~/.nvm
set -l brigand_nvm_fish_path $NVM_DIR/versions/node
if test (count $argv[1]) -lt 1
echo 'nvm-fast: at least one argument is required'
end
set -l command $argv[1]
if test $command = 'use'
set target_version "unknown"
if test (count $argv) -eq 1
if test -f .nvmrc
set target_version (cat .nvmrc)
else
echo "Error: No version provided and no .nvmrc found"
return
end
else
set target_version $argv[2]
end
set -l target_version $target_version
set -l matched_version (bash -c "source $NVM_DIR/nvm.sh --no-use; nvm_version $target_version")
if test -z $matched_version -o $matched_version = 'N/A'
echo "No version installed for $target_version, run nvm install $target_version"
echo "Installed versions: "
for file in $brigand_nvm_fish_path/v*
echo ' -' $file
end
else
set -l new_path (string match -ev "$brigand_nvm_fish_path" $PATH)
if test $matched_version != 'system'
set new_path $brigand_nvm_fish_path/$matched_version/bin $new_path
end
set -gx PATH $new_path
set -gx NVM_BIN (which node)
end
else
bash -c "source $NVM_DIR/nvm.sh --no-use; nvm $argv"
set -gx NVM_BIN (which node)
end
end
function nvm
switch "$FISH_VERSION"
case 2.0.0 2.1.0 2.1.1 2.1.2 2.2.0 2.2b1 2.3.0 2.3.1 2.3b1 2.3b2 2.4.0 2.4b1 2.5.0 2.5b1
echo "You need fish 2.6.0 or higher to use fast-nvm-fish." 1>&2
return 1
end
nvm-fast $argv
end

View file

@ -0,0 +1,26 @@
# 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_error e78284
fish_color_gray 737994
fish_color_selection --background=414559
fish_color_search_match --background=414559
fish_color_operator f4b8e4
ish_color_escape eebebe
fish_color_autosuggestion 737994
fish_color_cancel e78284
fish_color_cwd e5c890
fish_color_user 81c8be
fish_color_host 8caaee
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,26 @@
# 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_error d20f39
fish_color_gray 9ca0b0
fish_color_selection --background=ccd0da
fish_color_search_match --background=ccd0da
fish_color_operator ea76cb
fish_color_escape dd7878
fish_color_autosuggestion 9ca0b0
fish_color_cancel d20f39
fish_color_cwd df8e1d
fish_color_user 179299
fish_color_host 1e66f5
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,26 @@
# 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_error ed8796
fish_color_gray 6e738d
fish_color_selection --background=363a4f
fish_color_search_match --background=363a4f
fish_color_operator f5bde6
fish_color_escape f0c6c6
fish_color_autosuggestion 6e738d
fish_color_cancel ed8796
fish_color_cwd eed49f
fish_color_user 8bd5ca
fish_color_host 8aadf4
fish_pager_color_progress 6e738d
fish_pager_color_prefix f5bde6
fish_pager_color_completion cad3f5
fish_pager_color_description 6e738d

View file

@ -0,0 +1,26 @@
# name: 'Catppuccin mocha'
# url: 'https://github.com/catppuccin/fish'
# preferred_background: 1e1e2e
fish_color_normal cdd6f4
fish_color_command 89b4fa
fish_color_param f2cdcd
fish_color_keyword f38ba8
fish_color_quote a6e3a1
fish_color_redirection f5c2e7
fish_color_end fab387
fish_color_error f38ba8
fish_color_gray 6c7086
fish_color_selection --background=313244
fish_color_search_match --background=313244
fish_color_operator f5c2e7
fish_color_escape f2cdcd
fish_color_autosuggestion 6c7086
fish_color_cancel f38ba8
fish_color_cwd f9e2af
fish_color_user 94e2d5
fish_color_host 89b4fa
fish_pager_color_progress 6c7086
fish_pager_color_prefix f5c2e7
fish_pager_color_completion cdd6f4
fish_pager_color_description 6c7086