fish: add config, alias, abbr, env

This commit is contained in:
inkch 2024-01-17 10:24:24 +09:00
parent 52606bf8fd
commit c181c1ff3f
4 changed files with 634 additions and 0 deletions

View File

@ -0,0 +1,409 @@
# flush all abbreviations
for i in (abbr -l);
abbr -e $i;
end;
# ---------------------
abbr e "$EDITOR"
abbr se "sudo $EDITOR"
abbr vim "$EDITOR"
abbr vd 'nvim -d'
abbr vimd 'nvim -d'
abbr vimr 'nvim -R'
abbr Vim "vim"
abbr bash 'bash --rcfile ~/.config/bash/bashrc'
abbr df 'df -h'
abbr mv 'mv'
abbr less 'less -R'
abbr grep 'grep -n --color=always'
# abbr tree 'battree'
abbr tree 'batexa -a --tree --git-ignore --level=3'
abbr x 'xargs -I\'{}\''
abbr sedi "sed -i --follow-symlink 's///g'"
abbr cc 'copy-contents'
abbr P/ 'batpacsearch'
abbr Pc 'sudo paru -Rns (paru -Qtdq)'
abbr Pq 'paru -Q | fzf | awk \'{print $1}\' | xargs -I\'{}\' paru -Qi {}'
abbr Pr 'paru -Rs (paru -Q | fzf | awk \'{print $1}\' | xargs -I\'{}\' paru -Qi {} | head -1 | awk -F\' : \' \'{print $2}\')'
abbr Ps 'paru -S --skipreview --noconfirm'
abbr Pu 'paru -Syu --skipreview --noconfirm --quiet'
abbr uln 'unlink'
abbr cal 'cal -w -m'
if type -q update-all.sh
abbr ua 'update-all.sh'
end
if type -q unplug-key.sh
abbr uk 'unplug-key.sh'
end
abbr udb 'doas updatedb'
abbr ka 'killall'
# mozc setting dialog
if test -x /usr/lib/mozc/mozc_tool
abbr mozc-config '/usr/lib/mozc/mozc_tool --mode=config_dialog'
end
# youtube-dl abbreviations
# if type -q youtube-dl;
# abbr yd 'youtube-dl'
# abbr ydlomni 'youtube-dl --config-location "~/.config/youtube-dl/v-list"'
# # abbr ydl 'youtube-dl --config-location "~/.config/youtube-dl/v-list-u"'
# abbr ydl 'youtube-dl-parallel-list'
# abbr yda 'youtube-dl --config-location "~/.config/youtube-dl/audio"'
# abbr ydal 'youtube-dl --config-location "~/.config/youtube-dl/a-list"'
# end
abbr yd 'yt-dlpueue'
if type -q ytfzfdl;
abbr yfd ytfzfdl
end
# ffmpeg-wrapper(s)
if type -q ffmpeg;
type -q ffmpeg-split; and abbr ffsp 'ffmpeg-split'
type -q ffmpeg-wrapper; and abbr ffw 'ffmpeg-wrapper'
end
# Play youtube through mpv
# abbr yp 'setsid mpv --no-terminal --ytdl-raw-options=sub-lang=en --sid=1 --pause'
abbr yp 'mpv-play-youtube'
abbr yt "mpvytl --changed-within 3d"
abbr m "setsid mpv --no-terminal"
# nnn (filemanger)
if type -q nnn;
abbr nn 'nnn -Hrd'
if test -d /mnt/hdd
abbr nnh 'nnn -Hrd /mnt/hdd/'
end
if test -d /mnt/rpi4
abbr nnr 'nnn -Hrd /mnt/rpi4'
end
end
# systemd (systemctl)
abbr S 'sudo systemctl'
abbr Sr 'sudo systemctl restart'
abbr Ss 'sudo systemctl start'
abbr St 'sudo systemctl status'
abbr Se 'sudo systemctl enable'
abbr Sd 'sudo systemctl disable'
abbr Sp 'sudo systemctl stop'
abbr Su 'systemctl --user'
abbr Sur 'systemctl --user restart'
abbr Sus 'systemctl --user start'
abbr Sut 'systemctl --user status'
abbr Sue 'systemctl --user enable'
abbr Sud 'systemctl --user disable'
abbr Sup 'systemctl --user stop'
abbr Jc 'sudo journalctl'
abbr Jcu 'journalctl --user'
# poweroff
abbr pwo 'poweroff'
# change directory
abbr - 'cd -'
abbr .. 'cd ..'
abbr ... 'cd ../..'
abbr .... 'cd ../../..'
abbr ..... 'cd ../../../..'
abbr D 'cd ~/dl'
abbr M 'fuzzy-find -t d --exec /run/media/inkch/ 3'
abbr srv 'fuzzy-find -t d --exec /srv 3'
abbr jelly 'fuzzy-find -t d --exec /srv/jellyfin 3'
abbr hdd 'fuzzy-find -t d --exec /mnt/hdd 3'
abbr hdd2 'fuzzy-find -t d --exec /mnt/hdd2 3'
abbr BK 'fuzzy-find -t d --exec /mnt/hdd/bk 3'
abbr R 'fuzzy-find -t d --exec /mnt/rpi4 2'
abbr T 'cd ~/dl/torrent'
abbr cdw 'fuzzy-find -t d --exec ~/ws'
abbr f. 'fuzzy-find -t d --exec . 5'
abbr f.. 'bd'
abbr cdc 'fuzzy-find -t d --exec ~/.config 3'
abbr cdd 'fuzzy-find -t d --exec ~/dev 2'
abbr cde 'fuzzy-find -t d --exec /etc 4'
abbr cdf "fuzzy-find -t d --exec $XDG_DOCUMENTS_DIR/fons 2"
abbr cdk "fuzzy-find -t d --exec $XDG_DOCUMENTS_DIR/vimwiki 2"
abbr cdh 'fuzzy-find -t d --exec ~/hack'
abbr cdj "cd $XDG_DOCUMENTS_DIR/fons/journal"
abbr cdn "cd $XDG_DOCUMENTS_DIR/fons/notes"
abbr cdr "cd $XDG_DOCUMENTS_DIR/fons/review"
abbr cds "cd $XDG_DATA_HOME/myscripts"
abbr cdsys "cd $XDG_CONFIG_HOME/systemd/user"
abbr cdl 'fuzzy-find -t d --exec ~/.local'
abbr cdv 'fuzzy-find -t d --exec ~/vc'
# Dev Playgroud
abbr pg "cd ~/dev/pg && $EDITOR"
# Reload(source) config
# abbr sf "source (fd -HI -t f -e fish . $XDG_CONFIG_HOME/fish)"
abbr sf "source-fish-config"
abbr sff "source-fish-file"
abbr ff 'fuzzy-find -t f'
abbr fe 'fuzzy-find -t f --exec . 5'
abbr ,. 'fuzzy-find -t f --exec . 5'
# Edit config
abbr e. "fuzzy-find -t f --exec $PWD 5"
abbr e~ "fuzzy-find -t f --exec $HOME 7"
abbr ec "fuzzy-find -t f --exec $XDG_CONFIG_HOME 4"
abbr em "$EDITOR $XDG_DOCUMENTS_DIR/morningnote/(date +%Y-%m-%d).md"
abbr eci "$EDITOR $XDG_CONFIG_HOME/i3/config"
abbr ecp "$EDITOR $XDG_CONFIG_HOME/polybar/config"
abbr ew "fuzzy-find -t f --exec $XDG_DOCUMENTS_DIR/vimwiki"
# Edit fish-shell config/func/abbr
abbr ef "fuzzy-find -t f --exec $XDG_CONFIG_HOME/fish 2"
abbr efc "$EDITOR $XDG_CONFIG_HOME/fish/config.fish"
abbr efa "$EDITOR $XDG_CONFIG_HOME/fish/abbreviations.fish"
abbr eff "fuzzy-find -t f --exec $XDG_CONFIG_HOME/fish/functions 1 -E '__*'"
# Create new fish function
abbr nff "new-fish-function"
# Edit vim configs
abbr ev "fuzzy-find -t f --exec $XDG_CONFIG_HOME/nvim 3"
# Edit my own scripts
abbr es "fuzzy-find -t f --exec $XDG_DATA_HOME/myscripts 2"
# Transmission (torrent)
abbr trl "transmission-remote -l"
abbr trc "transmission-remote-cli"
# Git
abbr gs 'git status'
abbr gfe 'git fetch'
abbr gfa 'git fetch --all'
abbr gco 'git checkout'
abbr gcob 'git checkout -b'
abbr gcma 'git commit -am'
abbr gbr 'git branch'
abbr gbra 'git branch -a'
abbr gd 'git diff'
abbr gl 'git log --graph --decorate --oneline --date=iso'
abbr gemp 'git commit --allow-empty -m'
abbr gps "git remote | fzf -1 | xargs -I'{}' git push {}"
abbr gpl "git remote | fzf -1 | xargs -I'{}' git pull {}"
## Use interactive option all time
abbr rm 'rm -i'
abbr rmi 'rm -I'
abbr rmr 'rm -rI'
abbr rmd 'rmdir (fd -t d -t e)'
# abbr for `wishlist` (fish function)
abbr wish 'wishlist'
# Use advcpmv (Advanced cp & mv)
if type -q acp;
abbr cp 'acp -g'
# abbr bk 'acp -g -b'
else
abbr bk 'cp -b'
end
if type -q amv;
abbr mv 'amv -g'
end
## Use modern 'ls' replacement
if type -q exa;
if type -q batexa
abbr la 'batexa -lag --git'
abbr lad 'batexa -lagd --git'
else
abbr la 'exa -lag'
abbr lad 'exa -lagd'
end
abbr we "watchexa"
end
if type -q watchexec;
abbr wax 'watchexec'
end
## Use enhanced 'find'
if type -q fd;
abbr fde 'fd -H -e' # Filter by file extension
abbr fdd 'fd -H -t d' # File type "directory"
abbr fdE 'fd -H -t d -t empty' # File type "directory"
abbr fdf 'fd -H -t f' # File type "file"
abbr fdx 'fd -H -t x' # File type "executable"
abbr fdz "fd -H -t d | xargs -I'{}' zip {} -r {}"
end
if type -q docker;
abbr dockill "docker ps | fzf | awk '{ print $1 }' | xargs -I'{}' docker kill {}"
abbr docrm "docker ps -a | fzf | awk '{ print $1 }' | xargs -I'{}' docker rm {}"
abbr docrmi "docker images | fzf | awk '{ print $1 }' | xargs -I'{}' docker rmi {}"
end
if type -q grc;
abbr blkid 'grc blkid'
abbr cat 'bat'
abbr cpgrep 'colorpgrep'
abbr cvs 'grc cvs'
abbr df 'grc df -h'
abbr diff 'colordiff'
abbr digg 'grc digg'
abbr dnf 'grc dnf'
abbr docker 'grc docker'
abbr du 'grc du'
abbr env 'grc env'
abbr fdisk 'grc fdisk'
abbr findmnt 'grc findmnt'
abbr free 'grc free'
abbr g++ 'grc g++'
abbr gcc 'grc gcc'
abbr getfacl 'grc getfacl'
abbr getsebool 'grc getsebool'
abbr id 'grc id'
abbr iostat 'grc iostat'
# abbr ip 'grc ip'
abbr last 'grc last'
abbr lsattr 'grc lsattr'
abbr lsblk 'grc lsblk'
abbr lsmod 'grc lsmod'
abbr lsof 'grc lsof'
abbr lspci 'grc lspci'
abbr make 'grc make'
abbr mount 'grc mount'
abbr mtr 'grc mtr'
abbr netstat 'grc netstat'
abbr nmap 'grc nmap'
abbr ping 'grc ping -c 3'
abbr ps 'grc ps'
abbr sar 'grc sar'
abbr semanage 'grc semanage'
abbr showmount 'grc showmount'
abbr ss 'grc ss'
abbr stat 'grc stat'
abbr sysctl 'grc sysctl'
abbr tail 'grc tail'
abbr tcpdump 'grc tcpdump'
abbr traceroute 'grc traceroute'
abbr tune2fs 'grc tune2fs'
abbr ulimit 'ulimit'
abbr uptime 'grc uptime'
abbr vmstat 'grc vmstat'
abbr wdiff 'grc wdiff'
end
abbr ip 'ip -color=auto'
# frequently use
abbr ryt 'rsync -aAX --info=progress2 /mnt/hdd/vids/yt/ /mnt/rpi4/vids/yt --delete'
if type -q pueue
abbr ryta 'pueue add -- rsync -aAX --info=progress2 /mnt/hdd/vids/yt/ /mnt/rpi4/vids/yt --delete; pueue add -- rsync -aAX --info=progress2 /mnt/hdd/vids/_archive/ /mnt/rpi4/vids/_archive --delete'
else
abbr ryta 'rsync -aAX --info=progress2 /mnt/hdd/vids/yt/ /mnt/rpi4/vids/yt --delete; rsync -aAX --info=progress2 /mnt/hdd/vids/_archive/ /mnt/rpi4/vids/_archive --delete'
end
abbr pod 'fd -HI -t f --changed-within 30d . ~/.config/mpd/music/rapiko/output/audio | sort | sed "s;/home/inkch/.config/mpd/music/rapiko/output/audio/;;" | fzf | xargs -I'{}' mpc insert rapiko/output/audio/{}'
abbr nndl 'python ~/dev/nndownload/nndownload/nndownload.py -r 10 -u "vfcgxwho@gmail.com" -p "2Mrqxnp*GBHH#6z3e3@BIY!ZzJbcrias"'
# vimwiki
set -l wiki_root $XDG_DOCUMENTS_DIR/vimwiki
abbr ,ww "nvim -c 'cd $wiki_root | Goyo | VimwikiIndex'"
abbr ,wi "nvim -c 'cd $wiki_root | Goyo | VimwikiDiaryIndex'"
abbr ,w,w "nvim -c 'cd $wiki_root | Goyo | VimwikiMakeDiaryNote'"
# Rust
abbr rcr rust-compile-n-run
if type -q nvidia-settings
# nvidia-settings (To use XDG-Base-Directory)
abbr nvidia-settings 'nvidia-settings --config="$XDG_CONFIG_HOME/nvidia/settings"'
end
if type -q insect
abbr calc "insect"
else
abbr calc "echo 'Try `insect`. You can get it fron AUR.'"
end
if type -q z
abbr j "zi"
end
abbr h fiztory
if type -q fzf
abbr sshf "ssh (rg '^Host\s' ~/.ssh/config | cut -d' ' -f 2 | fzf)"
end
if type -q pueue
abbr pu pueue
abbr pus 'pueue status'
abbr pua 'pueue add --'
abbr pul "pueue log (pueue status | rg -o '^\s*[0-9]*\s.*[0-9]' | fzf --multi | cut -d' ' -f 2)"
abbr puf "pueue follow (pueue status | rg -o '^\s*[0-9]*\s.*[0-9]' | fzf --multi | cut -d' ' -f 2)"
abbr puc "pueue clean"
abbr puw "watch -cn 1 'pueue status'"
end
if type -q yarn
abbr ya "yarn --use-yarnrc ~/.config/yarn/yarnrc"
abbr yarn "yarn --use-yarnrc ~/.config/yarn/yarnrc"
end
if type -q vultr-cli
abbr vultr vultr-cli --config $XDG_CONFIG_HOME/vultr-cli/config.yaml
end
if type -q gfold
abbr gf gfold -d classic
end
if type -q zathura
abbr za "zathura (exa ~/dl/pdf | fzf)"
end
# udiskie
if type -q udiskie
abbr udi "udiskie"
end
if type -q udiskie-mount
abbr udim "udiskie-mount"
end
if type -q udiskie-umount
abbr udiu "udiskie-umount"
end
if test -f ~/esp/esp-idf/export.fish
abbr get_idf ". ~/esp/esp-idf/export.fish"
end
if type -q parallel
abbr pa 'parallel'
end
if type -q parallel and type -q aunpack
abbr paun 'parallel aunpack "{}" :::'
end
if type -q mcomix
abbr mx mcomix
end
if type -q chezmoi
abbr cz chezmoi
end

View File

@ -0,0 +1,29 @@
# alias bash "bash --init-file $XDG_CONFIG_HOME/bash/bashrc"
# alias vimpager "vimpager -c \"silent call <SNR>1_ToggleLess()\" "
# subversion
# alias svn 'svn --config-dir "$XDG_CONFIG_HOME"/subversion'
# cargo (rust)
# if type -q cargo
# alias ca 'cargo'
# end
# if type -q source-highlight
# alias ccat "source-highlight --out-format esc -o STDOUT -i"
# # alias pcat "source-highlight --out-format esc -o STDOUT"
# alias pcat "/usr/bin/source-highlight-esc.sh "
# end
# if type -q abcde && test -f $XDG_CONFIG_HOME/abcde.conf
# alias abcde "abcde -c ~/.config/abcde.conf"
# end
# if type -q newsboat
# alias news "pkill newsboat; timeout 10m newsboat; setsid $XDG_CONFIG_HOME/newsboat/ytdl.fish > /dev/null 2>&1"
# end
if type -q yarn
alias yarn "yarn --use-yarnrc '$XDG_CONFIG_HOME/yarn/config'"
end

View File

@ -0,0 +1,19 @@
set -x 0 fish
source $HOME/.config/fish/env.fish
# ONLY for interactive shell
if status --is-interactive
source $HOME/.config/fish/abbreviations.fish
set -q fish_private_mode && set -x FISH_IS_IN_PRIVATE 1
command -v zoxide > /dev/null && zoxide init fish | source
command -v starship > /dev/null && starship init fish | source
end
{{- if (and (eq .chezmoi.os "linux") (eq .hosttype "desktop" "laptop")) }}
if status --is-login
if test -z "$DISPLAY" -a "$XDG_VTNR" = 1
exec startx $HOME/.config/X11/xinitrc -- -keeptty -ardelay 200 -arinterval 60
end
end
{{- end }}

View File

@ -0,0 +1,177 @@
{{- if (and (eq .chezmoi.os "linux") (eq .hosttype "desktop" "laptop")) }}
# XDG directory settings have been already done in /home/inkch/.config/X11/xprofile
{{- end }}
set -x XDG_RUNTIME_DIR /run/user/{{ .chezmoi.uid }}
set -x XDG_CONFIG_HOME "$HOME/.config"
set -x XDG_CACHE_HOME "$HOME/.cache"
set -x XDG_DATA_HOME "$HOME/.local/share"
set -x XDG_DESKTOP_DIR "$HOME/vc/desk"
set -x XDG_DOCUMENTS_DIR "$HOME/vc/docs"
set -x XDG_DOWNLOAD_DIR "$HOME/dl"
set -x XDG_MUSIC_DIR "$HOME/vc/audio"
set -x XDG_PICTURES_DIR "$HOME/vc/pix"
set -x XDG_VIDEOS_DIR "$HOME/vc/vids"
set -x PATH $HOME/.local/bin $PATH
# Editor
if type -q nvim;
set -x EDITOR 'nvim'
else if type -q vim;
set -x EDITOR 'vim'
else
set -x EDITOR 'vi'
end
# for 'man'. See below;
# https://wiki.archlinux.org/title/Color_output_in_console
# set -x LESSOPEN "| /usr/bin/source-highlight-esc.sh %s"
set -x LESS_TERMCAP_md (printf "\e[01;31m")
set -x LESS_TERMCAP_me (printf "\e[0m")
set -x LESS_TERMCAP_se (printf "\e[0m")
set -x LESS_TERMCAP_so (printf "\e[01;44;33m")
set -x LESS_TERMCAP_ue (printf "\e[0m")
set -x LESS_TERMCAP_us (printf "\e[01;32m")
# for 'less'
set -x LESS '-RI'
set -x LESSHISTFILE '-'
# nnn (filemanager) settings
set -x NNN_CONTEXT_COLORS '4231'
set -x NNN_BMS 'j:/mnt/hdd2;l:/mnt/hdd2/vids/films;m:/mnt/;h:/mnt/hdd/;d:~/dl;t:~/dl/torrent;.:~/.config'
# python
set -x PYTHONSTARTUP $XDG_CONFIG_HOME/pythonrc
# ripgrep (rg)
set -x RIPGREP_CONFIG_PATH $XDG_CONFIG_HOME/ripgreprc
# xorg-xauth
# This line will break some DMs.
set -x XAUTHORITY "$XDG_RUNTIME_DIR/Xauthority"
# xinit
set -x XINITRC "$XDG_CONFIG_HOME/X11/xinitrc"
set -x XSERVERRC "$XDG_CONFIG_HOME/X11/xserverrc"
# nodejs
set -x NODE_REPL_HISTORY $XDG_CACHE_HOME/node_repl_history
set -x NPM_CONFIG_USERCONFIG $XDG_CONFIG_HOME/npm/npmrc
set -x PATH $XDG_DATA_HOME/npm/bin $PATH
# nvm
# set -x NVM_DIR $XDG_DATA_HOME/nvm
# volta
set -x VOLTA_HOME $XDG_DATA_HOME/volta
set -x PATH "$VOLTA_HOME/bin" $PATH
# python & pylint
set -x PYLINTHOME "$XDG_CACHE_HOME"/pylint
# golang
set -x GOPATH "$XDG_DATA_HOME/go"
set -x PATH $GOPATH/bin $PATH
# Rust
set -x RUSTUP_HOME $XDG_DATA_HOME/rustup
set -x CARGO_HOME $XDG_DATA_HOME/cargo
set -x PATH $PATH $CARGO_HOME/bin
# Parallel
set -x PARALLEL_HOME $XDG_CACHE_HOME/parallel
# source-highlight
set -x SOURCE_HIGHLIGHT_DATADIR /usr/share/source-highlight
# `pass` command
set -x PASSWORD_STORE_DIR $XDG_DATA_HOME/password-store
# ~/.rnd -> $XDG_CACHE_HOME/rnd
set -x RANDFILE $XDG_CACHE_HOME/rnd
# gpg (gnupg)
set -x GNUPGHOME $XDG_DATA_HOME/gnupg
# Filezilla
set -x FZ_DATADIR $XDG_DATA_HOME/filezilla
# my own scripts
set -x PATH $XDG_DATA_HOME/myscripts $PATH
# john the ripper
set -x JOHN $XDG_DATA_HOME/john
# bat (cat clone written in Rust)
if type -q bat;
# set -x BAT_THEME "hybrid"
set -x BAT_THEME "base16"
set -x BAT_PAGER "less -RFI"
set -x PAGER 'bat -p'
end
if type -q fzf;
set -x FZF_DEFAULT_OPTS ''
set -xa FZF_DEFAULT_OPTS --height=50%
set -xa FZF_DEFAULT_OPTS --layout=reverse
set -xa FZF_DEFAULT_OPTS --bind=ctrl-k:kill-line
end
if type -q sk;
set -x SKIM_DEFAULT_OPTIONS ''
set -xa SKIM_DEFAULT_OPTIONS --height=50%
set -xa SKIM_DEFAULT_OPTIONS --layout=reverse
set -xa SKIM_DEFAULT_OPTIONS --bind=ctrl-k:kill-line
end
if type -q sdcv;
set -x STARDICT_DATA_DIR "$XDG_DATA_HOME/stardict"
end
if type -q elinks;
set -x ELINKS_CONFDIR "$XDG_CONFIG_HOME/elinks"
end
if type -q docker;
set -x DOCKER_CONFIG "$XDG_CONFIG_HOME/docker"
end
if type -q gem;
set -x PATH "$XDG_DATA_HOME/gem/ruby/2.7.0/bin" $PATH
end
if test -f "$XDG_CONFIG_HOME"/mpd/mpd.conf;
set -x MPD_HOST (grep -n --color=always '^bind_to_address' $XDG_CONFIG_HOME/mpd/mpd.conf | awk -F' ' '{print $2}' | sed 's/"//g')
end
if type -q vidir;
set -x VIDIR_EDITOR_ARGS '-c :set nolist | :set ft=vidir-ls'
end
if type -q stack: # Haskell
set -x STACK_ROOT "$XDG_DATA_HOME"/stack
end
{{- if (and (eq .chezmoi.os "linux") (eq .hosttype "desktop" "laptop")) }}
if test -d "$XDG_DATA_HOME/flatpak/exports/bin"
set -ax PATH "$XDG_DATA_HOME/flatpak/exports/bin"
else if test -d "$HOME/.local/share/flatpak/exports/bin"
set -ax PATH "$HOME/.local/share/flatpak/exports/bin"
end
if test -d /var/lib/flatpak/exports/bin
set -ax PATH "/var/lib/flatpak/exports/bin"
end
if type -q calibre;
set -x CALIBRE_USE_DARK_PALETTE 1
end
if type -q ksshaskpass:
set -x SSH_ASKPASS (which ksshaskpass)
set -x SUDO_ASKPASS (which ksshaskpass)
end
{{- end }}