fish: Make all aliases into functions
Using alias inside ~/.config/fish/config.fish can slow down shell start as each alias/function will be eagerly loaded. alias is slow because it involves eval. functions support lazy/auto loading. https://fishshell.com/docs/current/tutorial.html#autoloading-functions
This commit is contained in:
parent
b8ccdaacd6
commit
0d0480a6b2
46 changed files with 138 additions and 61 deletions
|
@ -16,67 +16,6 @@ else
|
||||||
export EDITOR="nvim"
|
export EDITOR="nvim"
|
||||||
end
|
end
|
||||||
|
|
||||||
alias b="cd .."
|
|
||||||
alias c="clear"
|
|
||||||
alias m="mutt"
|
|
||||||
alias v="nvim"
|
|
||||||
alias vc="nvim --clean"
|
|
||||||
alias vn="nvim -u NONE"
|
|
||||||
alias vnrc="nvim -u NORC"
|
|
||||||
alias vnp="nvim --noplugin"
|
|
||||||
alias tksa="tmux kill-session -a"
|
|
||||||
alias tks="tmux kill-server"
|
|
||||||
alias tat="tmux attach -t "
|
|
||||||
alias tls="tmux ls"
|
|
||||||
alias vf="v (fzf)"
|
|
||||||
alias cs="cscope -bqR"
|
|
||||||
alias cat="bat"
|
|
||||||
alias t="tokei ."
|
|
||||||
alias gst="gst-inspect-1.0"
|
|
||||||
alias gsl="gst-launch-1.0"
|
|
||||||
alias sds="systemctl status "
|
|
||||||
alias sde="systemctl enable "
|
|
||||||
alias sdd="systemctl disable "
|
|
||||||
alias sfc="source ~/.config/fish/config.fish"
|
|
||||||
alias icat="kitty +kitten icat (fzf)"
|
|
||||||
alias jb="journalctl -r -b -1"
|
|
||||||
alias jf="journalctl -f"
|
|
||||||
alias jk="journalctl -r -k"
|
|
||||||
alias jr="journalctl -r"
|
|
||||||
alias ju="journalctl -u"
|
|
||||||
alias jx="journalctl -xe"
|
|
||||||
alias dpw="pw-dump | jq | nvim -c 'setlocal ft=json' -R"
|
|
||||||
|
|
||||||
# Git helpers
|
|
||||||
alias vg="vgrep"
|
|
||||||
alias vs="vgrep -s"
|
|
||||||
|
|
||||||
# Open fugitive with nvim directly
|
|
||||||
alias gn="nvim +Git +only"
|
|
||||||
|
|
||||||
# Open modified files
|
|
||||||
# ACMRU = Added || Copied || Modified || Renamed || Unmerged
|
|
||||||
# Edit all uncommitted files that have changes since the last commit (be they staged or unstaged)
|
|
||||||
alias vd="nvim (git diff HEAD --name-only --diff-filter=ACMR)"
|
|
||||||
# Edit all staged files that have changes since the last commit
|
|
||||||
alias vds="nvim (git diff --staged --name-only --diff-filter=ACMR)"
|
|
||||||
# Edit all files that were altered in the last commit
|
|
||||||
alias vdc="nvim (git diff HEAD^ --name-only --diff-filter=ACMR)"
|
|
||||||
# Edit files changed since master
|
|
||||||
alias vdm="nvim (git diff master --name-only --diff-filter=ACMR)"
|
|
||||||
# Edit files unmerged
|
|
||||||
alias vdu="nvim (git diff --name-only --diff-filter=U | uniq)"
|
|
||||||
# Add unmerged files
|
|
||||||
alias vdua="git add (git diff --name-only --diff-filter=U)"
|
|
||||||
|
|
||||||
# Cargo aliases
|
|
||||||
alias cba='cargo update && cargo build --all && cargo doc'
|
|
||||||
alias cbb='cargo build --all'
|
|
||||||
alias cbc='cargo clean'
|
|
||||||
alias cbd='cargo doc'
|
|
||||||
alias cbD='cargo doc --open'
|
|
||||||
alias cbu='cargo update'
|
|
||||||
|
|
||||||
fzf_key_bindings
|
fzf_key_bindings
|
||||||
|
|
||||||
# https://github.com/fish-shell/fish-shell/issues/7485#issuecomment-728984689
|
# https://github.com/fish-shell/fish-shell/issues/7485#issuecomment-728984689
|
||||||
|
|
3
fish/.config/fish/functions/b.fish
Normal file
3
fish/.config/fish/functions/b.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function b --wraps='cd ..' --description 'alias b=cd ..'
|
||||||
|
cd .. $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/c.fish
Normal file
3
fish/.config/fish/functions/c.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function c --wraps=clear --description 'alias c=clear'
|
||||||
|
clear $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/cat.fish
Normal file
3
fish/.config/fish/functions/cat.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function cat --wraps=bat --description 'alias cat=bat'
|
||||||
|
bat $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/cbD.fish
Normal file
3
fish/.config/fish/functions/cbD.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function cbD --wraps='cargo doc --open' --description 'alias cbD=cargo doc --open'
|
||||||
|
cargo doc --open $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/cba.fish
Normal file
3
fish/.config/fish/functions/cba.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function cba --wraps='cargo update && cargo build --all && cargo doc' --description 'alias cba=cargo update && cargo build --all && cargo doc'
|
||||||
|
cargo update && cargo build --all && cargo doc $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/cbb.fish
Normal file
3
fish/.config/fish/functions/cbb.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function cbb --wraps='cargo build --all' --description 'alias cbb=cargo build --all'
|
||||||
|
cargo build --all $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/cbc.fish
Normal file
3
fish/.config/fish/functions/cbc.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function cbc --wraps='cargo clean' --description 'alias cbc=cargo clean'
|
||||||
|
cargo clean $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/cbd.fish
Normal file
3
fish/.config/fish/functions/cbd.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function cbd --wraps='cargo doc' --description 'alias cbd=cargo doc'
|
||||||
|
cargo doc $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/cbu.fish
Normal file
3
fish/.config/fish/functions/cbu.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function cbu --wraps='cargo update' --description 'alias cbu=cargo update'
|
||||||
|
cargo update $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/dpw.fish
Normal file
3
fish/.config/fish/functions/dpw.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function dpw --wraps=pw-dump\ \|\ jq\ \|\ nvim\ -c\ \'setlocal\ ft=json\'\ -R --description alias\ dpw=pw-dump\ \|\ jq\ \|\ nvim\ -c\ \'setlocal\ ft=json\'\ -R
|
||||||
|
pw-dump | jq | nvim -c 'setlocal ft=json' -R $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/gn.fish
Normal file
3
fish/.config/fish/functions/gn.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function gn --wraps='nvim +Git +only' --description 'alias gn=nvim +Git +only'
|
||||||
|
nvim +Git +only $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/gsl.fish
Normal file
3
fish/.config/fish/functions/gsl.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function gsl --wraps=gst-launch-1.0 --description 'alias gsl=gst-launch-1.0'
|
||||||
|
gst-launch-1.0 $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/gst.fish
Normal file
3
fish/.config/fish/functions/gst.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function gst --wraps=gst-inspect-1.0 --description 'alias gst=gst-inspect-1.0'
|
||||||
|
gst-inspect-1.0 $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/icat.fish
Normal file
3
fish/.config/fish/functions/icat.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function icat --wraps='kitty +kitten icat (fzf)' --description 'alias icat=kitty +kitten icat (fzf)'
|
||||||
|
kitty +kitten icat (fzf) $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/jb.fish
Normal file
3
fish/.config/fish/functions/jb.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function jb --wraps='journalctl -r -b -1' --description 'alias jb=journalctl -r -b -1'
|
||||||
|
journalctl -r -b -1 $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/jf.fish
Normal file
3
fish/.config/fish/functions/jf.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function jf --wraps='journalctl -f' --description 'alias jf=journalctl -f'
|
||||||
|
journalctl -f $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/jk.fish
Normal file
3
fish/.config/fish/functions/jk.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function jk --wraps='journalctl -r -k' --description 'alias jk=journalctl -r -k'
|
||||||
|
journalctl -r -k $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/jr.fish
Normal file
3
fish/.config/fish/functions/jr.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function jr --wraps='journalctl -r' --description 'alias jr=journalctl -r'
|
||||||
|
journalctl -r $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/ju.fish
Normal file
3
fish/.config/fish/functions/ju.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function ju --wraps='journalctl -u' --description 'alias ju=journalctl -u'
|
||||||
|
journalctl -u $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/jx.fish
Normal file
3
fish/.config/fish/functions/jx.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function jx --wraps='journalctl -xe' --description 'alias jx=journalctl -xe'
|
||||||
|
journalctl -xe $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/lg.fish
Normal file
3
fish/.config/fish/functions/lg.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function lg
|
||||||
|
lazygit -ucd ~/.config/lazygit
|
||||||
|
end
|
3
fish/.config/fish/functions/m.fish
Normal file
3
fish/.config/fish/functions/m.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function m --wraps=mutt --description 'alias m=mutt'
|
||||||
|
mutt $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/sdd.fish
Normal file
3
fish/.config/fish/functions/sdd.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function sdd --wraps='systemctl disable ' --description 'alias sdd=systemctl disable '
|
||||||
|
systemctl disable $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/sde.fish
Normal file
3
fish/.config/fish/functions/sde.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function sde --wraps='systemctl enable ' --description 'alias sde=systemctl enable '
|
||||||
|
systemctl enable $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/sds.fish
Normal file
3
fish/.config/fish/functions/sds.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function sds --wraps='systemctl status ' --description 'alias sds=systemctl status '
|
||||||
|
systemctl status $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/sfc.fish
Normal file
3
fish/.config/fish/functions/sfc.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function sfc --wraps='source ~/.config/fish/config.fish' --description 'alias sfc=source ~/.config/fish/config.fish'
|
||||||
|
source ~/.config/fish/config.fish $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/t.fish
Normal file
3
fish/.config/fish/functions/t.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function t --wraps='tokei .' --description 'alias t=tokei .'
|
||||||
|
tokei . $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/tat.fish
Normal file
3
fish/.config/fish/functions/tat.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function tat --wraps='tmux attach -t ' --description 'alias tat=tmux attach -t '
|
||||||
|
tmux attach -t $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/tks.fish
Normal file
3
fish/.config/fish/functions/tks.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function tks --wraps='tmux kill-server' --description 'alias tks=tmux kill-server'
|
||||||
|
tmux kill-server $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/tksa.fish
Normal file
3
fish/.config/fish/functions/tksa.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function tksa --wraps='tmux kill-session -a' --description 'alias tksa=tmux kill-session -a'
|
||||||
|
tmux kill-session -a $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/tls.fish
Normal file
3
fish/.config/fish/functions/tls.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function tls --wraps='tmux ls' --description 'alias tls=tmux ls'
|
||||||
|
tmux ls $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/v.fish
Normal file
3
fish/.config/fish/functions/v.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function v --wraps=nvim --description 'alias v=nvim'
|
||||||
|
nvim $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/vc.fish
Normal file
3
fish/.config/fish/functions/vc.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function vc --wraps='nvim --clean' --description 'alias vc=nvim --clean'
|
||||||
|
nvim --clean $argv;
|
||||||
|
end
|
6
fish/.config/fish/functions/vd.fish
Normal file
6
fish/.config/fish/functions/vd.fish
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# Open modified files
|
||||||
|
# ACMRU = Added || Copied || Modified || Renamed || Unmerged
|
||||||
|
# Edit all uncommitted files that have changes since the last commit (be they staged or unstaged)
|
||||||
|
function vd --wraps='nvim (git diff HEAD --name-only --diff-filter=ACMR)' --description 'alias vd=nvim (git diff HEAD --name-only --diff-filter=ACMR)'
|
||||||
|
nvim (git diff HEAD --name-only --diff-filter=ACMR) $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/vdc.fish
Normal file
3
fish/.config/fish/functions/vdc.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function vdc --wraps='nvim (git diff HEAD^ --name-only --diff-filter=ACMR)' --description 'Edit all files that were altered in the last commit'
|
||||||
|
nvim (git diff HEAD^ --name-only --diff-filter=ACMR) $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/vdm.fish
Normal file
3
fish/.config/fish/functions/vdm.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function vdm --wraps='nvim (git diff master --name-only --diff-filter=ACMR)' --description 'Edit files changed since master'
|
||||||
|
nvim (git diff master --name-only --diff-filter=ACMR) $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/vds.fish
Normal file
3
fish/.config/fish/functions/vds.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function vds --wraps='nvim (git diff --staged --name-only --diff-filter=ACMR)' --description 'Edit all staged files that have changes since the last commit'
|
||||||
|
nvim (git diff --staged --name-only --diff-filter=ACMR) $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/vdu.fish
Normal file
3
fish/.config/fish/functions/vdu.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function vdu --wraps='nvim (git diff --name-only --diff-filter=U | uniq)' --description 'Edit files unmerged'
|
||||||
|
nvim (git diff --name-only --diff-filter=U | uniq) $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/vdua.fish
Normal file
3
fish/.config/fish/functions/vdua.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function vdua --wraps='git add (git diff --name-only --diff-filter=U)' --description 'Add unmerged files'
|
||||||
|
git add (git diff --name-only --diff-filter=U) $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/vf.fish
Normal file
3
fish/.config/fish/functions/vf.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function vf --wraps='v (fzf)' --description 'alias vf=v (fzf)'
|
||||||
|
v (fzf) $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/vg.fish
Normal file
3
fish/.config/fish/functions/vg.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function vg --wraps=vgrep --description 'alias vg=vgrep'
|
||||||
|
vgrep $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/vn.fish
Normal file
3
fish/.config/fish/functions/vn.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function vn --wraps='nvim -u NONE' --description 'alias vn=nvim -u NONE'
|
||||||
|
nvim -u NONE $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/vnp.fish
Normal file
3
fish/.config/fish/functions/vnp.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function vnp --wraps='nvim --noplugin' --description 'alias vnp=nvim --noplugin'
|
||||||
|
nvim --noplugin $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/vnrc.fish
Normal file
3
fish/.config/fish/functions/vnrc.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function vnrc --wraps='nvim -u NORC' --description 'alias vnrc=nvim -u NORC'
|
||||||
|
nvim -u NORC $argv;
|
||||||
|
end
|
3
fish/.config/fish/functions/vs.fish
Normal file
3
fish/.config/fish/functions/vs.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function vs --wraps='vgrep -s' --description 'alias vs=vgrep -s'
|
||||||
|
vgrep -s $argv;
|
||||||
|
end
|
Loading…
Reference in a new issue