fish: standardize config structure
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
if not set -q fetch_logo_type
|
||||
set -g fetch_logo_type kitty
|
||||
end
|
||||
|
||||
if test $(pgrep -u $USER -x kitty | wc -l) -ge 2
|
||||
set -g no_fetch
|
||||
end
|
||||
|
||||
spotify-lyrics completion fish | source
|
||||
|
||||
alias gduu "sudo gdu -i /media/Alpha -i /media/Beta -i /media/Gamma -i /.snapshots -i /home/.snapshots /"
|
||||
@@ -0,0 +1,28 @@
|
||||
# PATH
|
||||
fish_add_path $HOME/go/bin
|
||||
fish_add_path $HOME/.cargo/bin
|
||||
fish_add_path $HOME/.local/scripts
|
||||
fish_add_path $HOME/.local/bin
|
||||
|
||||
# man
|
||||
if type -q bat
|
||||
set -x -g MANPAGER "sh -c 'col -bx | bat -l man -p'"
|
||||
set -x -g MANROFFOPT -c
|
||||
end
|
||||
|
||||
# Editor
|
||||
for app in nvim helix vim vi nano
|
||||
if type -q $app
|
||||
set -x -g EDITOR $app
|
||||
set -x -g VISUAL $app
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
# Create shortcut alias for helix
|
||||
if type -q helix; and not type -q hx
|
||||
alias hx helix
|
||||
end
|
||||
|
||||
# gpg
|
||||
set -x -g GPG_TTY (tty)
|
||||
@@ -0,0 +1,22 @@
|
||||
if test -n "$XDG_CURRENT_DESKTOP"; and test "$XDG_CURRENT_DESKTOP" = "niri"
|
||||
set -l env_config "$HOME/.config/niri/config/envs.kdl"
|
||||
|
||||
if test -f "$env_config"
|
||||
while read -la line
|
||||
# Remove comments
|
||||
set line (string replace -r '//.*' '' -- "$line")
|
||||
# Trim whitespace
|
||||
set line (string trim -- "$line")
|
||||
# Skip "environment" block lines
|
||||
if test -z "$line"; or string match -q "environment*" -- "$line"; or test "$line" = "}"
|
||||
continue
|
||||
end
|
||||
# Match lines like: VARIABLE "value" where VARIABLE is alphanumeric/underscore
|
||||
set -l matches (string match -r '^([0-9A-Za-z_]+)\s+"(.*)"$' -- "$line")
|
||||
# If have a matches, set the environment variable
|
||||
if test (count $matches) -eq 3
|
||||
set -xg $matches[2] $matches[3]
|
||||
end
|
||||
end < "$env_config"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
# ssh with encrypted private keys
|
||||
# $ssh_keys should be set in advance or left empty to use the default keys
|
||||
if type -q ssh
|
||||
bass $(ssh-init) > /dev/null 2>&1
|
||||
|
||||
# avoid entering passphrase every time
|
||||
function sshs
|
||||
# test if keys are added to ssh-agent
|
||||
if not ssh-add -l > /dev/null 2>&1
|
||||
ssh-add $ssh_keys
|
||||
end
|
||||
ssh $argv
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
function fish_prompt -d "Write out the prompt"
|
||||
# This shows up as USER@HOST /home/user/ >, with the directory colored
|
||||
# $USER and $hostname are set by fish, so you can just use them
|
||||
# instead of using `whoami` and `hostname`
|
||||
printf '%s@%s %s%s%s > ' $USER $hostname \
|
||||
(set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
|
||||
end
|
||||
|
||||
# oh-my-posh
|
||||
if test -f $HOME/.config/posh_theme.omp.json; and type -q oh-my-posh
|
||||
oh-my-posh init fish --config $HOME/.config/posh_theme.omp.json | source
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
set -l target_ver 4.3.0
|
||||
|
||||
if test (string join \n $FISH_VERSION $target_ver | sort -V | tail -n 1) = $target_ver
|
||||
set -l theme 'Catppuccin Mocha'
|
||||
|
||||
if not set -q fish_current_theme; or not string match -q "$theme" "$fish_current_theme"
|
||||
set -U fish_current_theme "$theme"
|
||||
fish_config theme save "$theme"
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,145 @@
|
||||
# fzf
|
||||
if type -q fzf
|
||||
fzf --fish | source
|
||||
|
||||
# auto copy fzf's output
|
||||
if type -q wl-copy
|
||||
alias fzf="fzf --bind 'enter:execute-silent(echo {+} | wl-copy --trim-newline)+accept'"
|
||||
end
|
||||
|
||||
# fzh: history
|
||||
alias fzh="history | fzf"
|
||||
|
||||
# fz: fuzzy find a file and preview
|
||||
if type -q bat
|
||||
alias fz="fzf --preview 'bat --style=numbers --color=always {}'"
|
||||
else
|
||||
alias fz="fzf --preview 'cat --number {}'"
|
||||
end
|
||||
|
||||
# fe: fuzzy find a file and edit using $EDITOR
|
||||
function fe
|
||||
set -l file $(fz $argv)
|
||||
if test -n "$file"
|
||||
$EDITOR "$file"
|
||||
end
|
||||
end
|
||||
|
||||
# fkill: fuzzy find a process and kill with SIGKILL
|
||||
function fkill
|
||||
set -l pids (ps -ef | sed 1d | fzf -m --preview 'pstree -p $(echo {} | awk "{print \$2}")' | awk '{print $2}')
|
||||
|
||||
if test -n "$pids"
|
||||
kill -9 $pids
|
||||
end
|
||||
end
|
||||
|
||||
if type -q yay
|
||||
# fyq: fuzzy yay query
|
||||
alias fyq="yay -Qq | fzf --preview 'yay -Qi {}'"
|
||||
|
||||
# fyi: fuzzy yay install
|
||||
function fyi
|
||||
set -l pkg (yay -Sl | awk '{print $1"/"$2}' | fzf -m --preview 'yay -Si {}' $argv)
|
||||
if test -n "$pkg"
|
||||
yay -S $pkg
|
||||
end
|
||||
end
|
||||
|
||||
# fyr: fuzzy yay remove
|
||||
function fyr
|
||||
set -l pkg (yay -Qq | fzf -m --preview 'yay -Qi {}' $argv)
|
||||
if test -n "$pkg"
|
||||
yay -Rn $pkg
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# cd
|
||||
if type -q zoxide
|
||||
zoxide init fish | source
|
||||
alias cd=z
|
||||
end
|
||||
|
||||
# rm
|
||||
if type -q trash
|
||||
alias rm="echo \"use 'trash' instead :)\" && sh -c \"exit 42\""
|
||||
end
|
||||
|
||||
# ls
|
||||
if type -q eza
|
||||
alias ll="eza -lh --group-directories-first --icons=auto"
|
||||
alias la="eza -lh --group-directories-first --icons=auto --all"
|
||||
alias lt="eza --tree --level=2 --long --icons --git"
|
||||
else
|
||||
alias ll="ls -lh --group-directories-first --color=auto"
|
||||
alias la="ls -lah --group-directories-first --color=auto"
|
||||
end
|
||||
|
||||
# directories
|
||||
alias ..='cd ..'
|
||||
alias ...='cd ../..'
|
||||
alias ....='cd ../../..'
|
||||
|
||||
# grep
|
||||
alias grep="grep --color=auto"
|
||||
|
||||
# others
|
||||
if type -q tty-clock
|
||||
alias clock="tty-clock -c -C 4"
|
||||
end
|
||||
|
||||
if type -q git
|
||||
function gcp
|
||||
if test (count $argv) -eq 0
|
||||
git commit -a -m "👐 foo: too lazy to come up with a helpful commit message :)" || return 1
|
||||
else
|
||||
git commit -a -m "$argv" || return 1
|
||||
end
|
||||
git push
|
||||
end
|
||||
|
||||
if type -q wl-paste
|
||||
# alias gc="git clone \$(wl-paste)"
|
||||
function gc
|
||||
set -l repo (wl-paste)
|
||||
if not string match -r '^(http|https|git|ssh)://|^git@' "$repo" >/dev/null 2>&1
|
||||
echo "Error: Clipboard does not contain a valid git repository URL." >&2
|
||||
echo "Error: Clipboard content: $repo" >&2
|
||||
read -P "Enter a valid git repository URL: " repo
|
||||
if not string match -r '^(http|https|git|ssh)://|^git@' "$repo"
|
||||
echo "Error: Invalid git repository URL." >&2
|
||||
return 1
|
||||
end
|
||||
end
|
||||
git clone $repo
|
||||
end
|
||||
|
||||
function pingo
|
||||
cd "$HOME/Repositories/PGdP" || return 1
|
||||
set -l repo (wl-paste)
|
||||
if not string match -r '^(http|https|git|ssh)://|^git@' "$repo" >/dev/null 2>&1
|
||||
echo "Error: Clipboard does not contain a valid git repository URL." >&2
|
||||
echo "Error: Clipboard content: $repo" >&2
|
||||
read -P "Enter a valid git repository URL: " repo
|
||||
if not string match -r '^(http|https|git|ssh)://|^git@' "$repo"
|
||||
echo "Error: Invalid git repository URL." >&2
|
||||
return 1
|
||||
end
|
||||
end
|
||||
set -l dir_name (basename "$repo" .git)
|
||||
if ! test -d "$dir_name"
|
||||
git clone $repo || return 1
|
||||
end
|
||||
set -l app $argv[1]
|
||||
if test -n "$app"; and type -q "$app"
|
||||
echo Opening project with "$app"
|
||||
nohup $app $dir_name >/dev/null 2>&1 & disown
|
||||
else
|
||||
echo Opening method missing or invalid
|
||||
cd $dir_name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,38 @@
|
||||
if not set -q fetch_logo_type
|
||||
set -g fetch_logo_type auto
|
||||
end
|
||||
|
||||
if not set -q fetch_color
|
||||
set -g fetch_color "#89b4fa"
|
||||
end
|
||||
|
||||
if test "$fetch_logo_type" = symbols
|
||||
set -g fetch_args "--logo-type raw --logo-width 42 --logo \"$HOME/.config/fastfetch/logo_ros/42x.symbols\" --color \"$fetch_color\""
|
||||
set -g fetch_args_brief "--logo-type raw --logo-width 28 --logo \"$HOME/.config/fastfetch/logo_ros/28x.symbols\" --color \"$fetch_color\""
|
||||
else if test "$fetch_logo_type" = logo
|
||||
set -g fetch_args "--logo-type builtin"
|
||||
set -g fetch_args_brief "--logo-type small"
|
||||
else if test "$fetch_logo_type" = sixel
|
||||
set -g fetch_args "--logo-type raw --logo-width 42 --logo \"$HOME/.config/fastfetch/logo_ros/42x.sixel\" --color \"$fetch_color\""
|
||||
set -g fetch_args_brief "--logo-type raw --logo-width 28 --logo \"$HOME/.config/fastfetch/logo_ros/28x.sixel\" --color \"$fetch_color\""
|
||||
else # "kitty" or "auto" and others
|
||||
set -g fetch_args "--logo-type $fetch_logo_type --logo-width 42 --logo \"$HOME/.config/fastfetch/logo_ros/ros.png\" --color \"$fetch_color\""
|
||||
set -g fetch_args_brief "--logo-type $fetch_logo_type --logo-width 28 --logo \"$HOME/.config/fastfetch/logo_ros/ros.png\" --color \"$fetch_color\""
|
||||
end
|
||||
|
||||
if type -q fastfetch
|
||||
alias ff="fastfetch -c $HOME/.config/fastfetch/config.jsonc $fetch_args"
|
||||
|
||||
if test -f "$HOME/.config/fastfetch/brief.jsonc"
|
||||
alias ffb="fastfetch -c $HOME/.config/fastfetch/brief.jsonc $fetch_args_brief"
|
||||
else
|
||||
alias ffb=ff
|
||||
end
|
||||
end
|
||||
|
||||
# add 'set -g no_fetch' somewhere other than post.d to disable fetching
|
||||
if not set -q no_fetch
|
||||
if type -q ffb
|
||||
ffb
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user