diff --git a/.config/fish/functions/cat.fish b/.config/fish/functions/cat.fish index 91062475..91b25479 100644 --- a/.config/fish/functions/cat.fish +++ b/.config/fish/functions/cat.fish @@ -1,3 +1,7 @@ function cat --wraps=bat --description 'alias cat=bat' - bat $argv + if type -f bat &>/dev/null + bat $argv + else + cat $argv + end end diff --git a/.config/fish/functions/catp.fish b/.config/fish/functions/catp.fish index f3410e76..96b2207d 100644 --- a/.config/fish/functions/catp.fish +++ b/.config/fish/functions/catp.fish @@ -1,3 +1,7 @@ function catp --wraps='bat --paging=always' --description 'alias catp=bat --paging=always' - bat --paging=always $argv + if type -f bat &>/dev/null + bat --paging=always $argv + else + cat --paging=always $argv + end end diff --git a/.config/fish/functions/codeinfo.fish b/.config/fish/functions/codeinfo.fish index f3b8b79a..0d449966 100644 --- a/.config/fish/functions/codeinfo.fish +++ b/.config/fish/functions/codeinfo.fish @@ -1,3 +1,7 @@ function codeinfo --wraps='scc ./' --description 'alias codeinfo=scc ./' - scc ./ $argv + if type -f scc &>/dev/null + scc ./ $argv + else + missing_package scc + end end diff --git a/.config/fish/functions/disks.fish b/.config/fish/functions/disks.fish index d9b882d8..7f2e8987 100644 --- a/.config/fish/functions/disks.fish +++ b/.config/fish/functions/disks.fish @@ -1,3 +1,7 @@ function disks --wraps=duf --description 'alias disks=duf' - duf $argv + if type -f duf &>/dev/null + duf $argv + else + missing_package duf + end end diff --git a/.config/fish/functions/dots.fish b/.config/fish/functions/dots.fish index 9d1d69c3..1e1e0812 100644 --- a/.config/fish/functions/dots.fish +++ b/.config/fish/functions/dots.fish @@ -1,4 +1,3 @@ function dots --description 'alias dots=yadm enter lazygit' - cd $HOME - yadm enter lazygit $argv + fish -c 'cd $HOME; yadm enter lazygit' end diff --git a/.config/fish/functions/dsize.fish b/.config/fish/functions/dsize.fish index 95cf566e..7ebdffa2 100644 --- a/.config/fish/functions/dsize.fish +++ b/.config/fish/functions/dsize.fish @@ -1,3 +1,7 @@ function dsize --wraps='dua i' --description 'alias dsize=dua i' - dua i $argv + if type -f dua &>/dev/null + dua i $argv + else + missing_package dua-cli + end end diff --git a/.config/fish/functions/ea.fish b/.config/fish/functions/ea.fish deleted file mode 100644 index 970a2946..00000000 --- a/.config/fish/functions/ea.fish +++ /dev/null @@ -1,3 +0,0 @@ -function ea --wraps='nvim ~/.config/fish/aliases.fish' --description 'alias ea=nvim ~/.config/fish/aliases.fish' - nvim ~/.config/fish/aliases.fish $argv -end diff --git a/.config/fish/functions/ef.fish b/.config/fish/functions/ef.fish deleted file mode 100644 index 5d410e3d..00000000 --- a/.config/fish/functions/ef.fish +++ /dev/null @@ -1,3 +0,0 @@ -function ef --wraps='nvim ~/.config/fish/config.fish' --description 'alias ef=nvim ~/.config/fish/config.fish' - nvim ~/.config/fish/config.fish $argv -end diff --git a/.config/fish/functions/eg.fish b/.config/fish/functions/eg.fish deleted file mode 100644 index f68182eb..00000000 --- a/.config/fish/functions/eg.fish +++ /dev/null @@ -1,3 +0,0 @@ -function eg --wraps='nvim ~/.gitconfig' --description 'alias eg=nvim ~/.gitconfig' - nvim ~/.gitconfig $argv -end diff --git a/.config/fish/functions/ev.fish b/.config/fish/functions/ev.fish deleted file mode 100644 index 98806285..00000000 --- a/.config/fish/functions/ev.fish +++ /dev/null @@ -1,3 +0,0 @@ -function ev --wraps='nvim ~/.config/fish/variables.fish' --description 'alias ev=nvim ~/.config/fish/variables.fish' - nvim ~/.config/fish/variables.fish $argv -end diff --git a/.config/fish/functions/f.fish b/.config/fish/functions/f.fish index bf7ed772..e07bc819 100644 --- a/.config/fish/functions/f.fish +++ b/.config/fish/functions/f.fish @@ -1,3 +1,7 @@ function f --wraps=fzf --description 'alias f=fzf' - fzf $argv + if type -f fzf &>/dev/null + fzf $argv + else + missing_package fzf + end end diff --git a/.config/fish/functions/fe.fish b/.config/fish/functions/fe.fish index 02aeb092..b16d6abd 100644 --- a/.config/fish/functions/fe.fish +++ b/.config/fish/functions/fe.fish @@ -1,8 +1,12 @@ function fe - set tmp (mktemp -t "yazi-cwd.XXXXX") - yazi --cwd-file="$tmp" - if set cwd (cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ] - cd -- "$cwd" + if type -f yazi &>/dev/null + set tmp (mktemp -t "yazi-cwd.XXXXX") + yazi --cwd-file="$tmp" + if set cwd (cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ] + cd -- "$cwd" + end + rm -f -- "$tmp" + else + missing_package yazi end - rm -f -- "$tmp" end diff --git a/.config/fish/functions/fetch.fish b/.config/fish/functions/fetch.fish index d7c29af9..ce670dd2 100644 --- a/.config/fish/functions/fetch.fish +++ b/.config/fish/functions/fetch.fish @@ -1,3 +1,7 @@ function fetch --wraps=fastfetch --description 'alias fetch=fastfetch' - fastfetch $argv + if type -f fastfetch &>/dev/null + fastfetch $argv + else + missing_package fastfetch + end end diff --git a/.config/fish/functions/gfetch.fish b/.config/fish/functions/gfetch.fish index fffa35e3..32494c1a 100644 --- a/.config/fish/functions/gfetch.fish +++ b/.config/fish/functions/gfetch.fish @@ -1,3 +1,7 @@ function gfetch --wraps=onefetch --description 'alias gfetch=onefetch' - onefetch $argv + if type -f onefetch &>/dev/null + onefetch $argv + else + missing_package onefetch + end end diff --git a/.config/fish/functions/gpt.fish b/.config/fish/functions/gpt.fish index 756bd3b7..06abcff1 100644 --- a/.config/fish/functions/gpt.fish +++ b/.config/fish/functions/gpt.fish @@ -1,3 +1,7 @@ function gpt --wraps='tgpt -i' --description 'alias gpt=tgpt -i' - tgpt $argv + if type -f tgpt &>/dev/null + tgpt $argv + else + missing_package tgpt + end end diff --git a/.config/fish/functions/info.fish b/.config/fish/functions/info.fish index 862abc87..93acd924 100644 --- a/.config/fish/functions/info.fish +++ b/.config/fish/functions/info.fish @@ -1,3 +1,7 @@ function info --wraps=tldr --description 'alias info=tldr' - tldr $argv + if type -f tldr &>/dev/null + tldr $argv + else + missing_package tldr + end end diff --git a/.config/fish/functions/l.fish b/.config/fish/functions/l.fish index a3a0f365..5f2e3280 100644 --- a/.config/fish/functions/l.fish +++ b/.config/fish/functions/l.fish @@ -1,3 +1,7 @@ function l --wraps='eza --long --header -a --icons --git --group-directories-first' --description 'alias l=eza --long --header -a --icons --git --group-directories-first' - eza --long --header -a --icons --git --group-directories-first --hyperlink $argv + if type -f eza &>/dev/null + eza --long --header -a --icons --git --group-directories-first --hyperlink $argv + else + missing_package eza + end end diff --git a/.config/fish/functions/ld.fish b/.config/fish/functions/ld.fish index 11f44eff..15899fb4 100644 --- a/.config/fish/functions/ld.fish +++ b/.config/fish/functions/ld.fish @@ -1,3 +1,7 @@ function ld --wraps=lazydocker --description 'alias ld=lazydocker' - lazydocker $argv + if type -f lazydocker &>/dev/null + lazydocker $argv + else + missing_package lazydocker + end end diff --git a/.config/fish/functions/ldh.fish b/.config/fish/functions/ldh.fish index b51f61cf..988ca9aa 100644 --- a/.config/fish/functions/ldh.fish +++ b/.config/fish/functions/ldh.fish @@ -1,3 +1,7 @@ function ldh --wraps='eza --long --header --icons -D --git' --description 'alias ldh=eza --long --header --icons -D --git' - eza --long --header --icons -D --git --hyperlink $argv + if type -f eza &>/dev/null + eza --long --header --icons -D --git --hyperlink $argv + else + missing_package eza + end end diff --git a/.config/fish/functions/lg.fish b/.config/fish/functions/lg.fish index 2d1cb1d2..d0306d1e 100644 --- a/.config/fish/functions/lg.fish +++ b/.config/fish/functions/lg.fish @@ -1,3 +1,7 @@ function lg --wraps=lazygit --description 'alias lg=lazygit' - lazygit $argv + if type -f eza &>/dev/null + lazygit $argv + else + missing_package lazygit + end end diff --git a/.config/fish/functions/lh.fish b/.config/fish/functions/lh.fish index 73a96e42..6f9522c0 100644 --- a/.config/fish/functions/lh.fish +++ b/.config/fish/functions/lh.fish @@ -1,3 +1,7 @@ function lh --wraps='eza --long --header --icons --git --group-directories-first' --description 'alias lh=eza --long --header --icons --git --group-directories-first' - eza --long --header --icons --git --group-directories-first --hyperlink $argv + if type -f eza &>/dev/null + eza --long --header --icons --git --group-directories-first --hyperlink $argv + else + missing_package eza + end end diff --git a/.config/fish/functions/ls.fish b/.config/fish/functions/ls.fish index f527cdd8..d99c7853 100644 --- a/.config/fish/functions/ls.fish +++ b/.config/fish/functions/ls.fish @@ -1,3 +1,7 @@ function ls --wraps='eza -a --icons --group-directories-first' --description 'alias ls=eza -a --icons --group-directories-first' - eza -a --icons --group-directories-first --hyperlink $argv + if type -f eza &>/dev/null + eza -a --icons --group-directories-first --hyperlink $argv + else + missing_package eza + end end diff --git a/.config/fish/functions/lsh.fish b/.config/fish/functions/lsh.fish index 56a6505b..aae12099 100644 --- a/.config/fish/functions/lsh.fish +++ b/.config/fish/functions/lsh.fish @@ -1,3 +1,7 @@ function lsh --wraps='eza --icons --git --group-directories-first' --description 'alias lsh=eza --icons --git --group-directories-first' - eza --icons --git --group-directories-first --hyperlink $argv + if type -f eza &>/dev/null + eza --icons --git --group-directories-first --hyperlink $argv + else + missing_package eza + end end diff --git a/.config/fish/functions/lt.fish b/.config/fish/functions/lt.fish index e3c3a182..be2de911 100644 --- a/.config/fish/functions/lt.fish +++ b/.config/fish/functions/lt.fish @@ -1,3 +1,7 @@ function lt --wraps='eza --long --header -a --icons --tree --git --group-directories-first' --description 'alias lt=eza --long --header -a --icons --tree --git --group-directories-first' - eza --long --header -a --icons --tree --git --group-directories-first --hyperlink $argv + if type -f eza &>/dev/null + eza --long --header -a --icons --tree --git --group-directories-first --hyperlink $argv + else + missing_package eza + end end diff --git a/.config/fish/functions/lth.fish b/.config/fish/functions/lth.fish index 42832b3c..6c076896 100644 --- a/.config/fish/functions/lth.fish +++ b/.config/fish/functions/lth.fish @@ -1,3 +1,7 @@ function lth --wraps='eza --long --header --icons --tree --git --group-directories-first' --description 'alias lth=eza --long --header --icons --tree --git --group-directories-first' - eza --long --header --icons --tree --git --group-directories-first --hyperlink $argv + if type -f eza &>/dev/null + eza --long --header --icons --tree --git --group-directories-first --hyperlink $argv + else + missing_package eza + end end diff --git a/.config/fish/functions/missing_package.fish b/.config/fish/functions/missing_package.fish new file mode 100644 index 00000000..0f21f202 --- /dev/null +++ b/.config/fish/functions/missing_package.fish @@ -0,0 +1,12 @@ +function missing_package + while true + read -l -P "$argv[1] not found. Do you want to install it? [y/N] " confirm + + if test "$confirm" = y + i $argv + break + else + break + end + end +end diff --git a/.config/fish/functions/ni.fish b/.config/fish/functions/ni.fish index cdc15154..485bdd07 100644 --- a/.config/fish/functions/ni.fish +++ b/.config/fish/functions/ni.fish @@ -1,3 +1,7 @@ function ni --wraps='npm install' --description 'alias ni=npm install' - npm install $argv + if type -f npm &>/dev/null + npm install $argv + else + missing_package npm + end end diff --git a/.config/fish/functions/nid.fish b/.config/fish/functions/nid.fish index d87fbdf5..d13bc60d 100644 --- a/.config/fish/functions/nid.fish +++ b/.config/fish/functions/nid.fish @@ -1,3 +1,7 @@ function nid --wraps='npm install --save-dev' --description 'alias nid=npm install --save-dev' - npm install --save-dev $argv + if type -f npm &>/dev/null + npm install --save-dev $argv + else + missing_package npm + end end diff --git a/.config/fish/functions/nis.fish b/.config/fish/functions/nis.fish index 9157ed62..352eb3a9 100644 --- a/.config/fish/functions/nis.fish +++ b/.config/fish/functions/nis.fish @@ -1,3 +1,7 @@ function nis --wraps='npm install --save' --description 'alias nis=npm install --save' - npm install --save $argv + if type -f npm &>/dev/null + npm install --save $argv + else + missing_package npm + end end diff --git a/.config/fish/functions/nls.fish b/.config/fish/functions/nls.fish index c33ab521..cb50a7da 100644 --- a/.config/fish/functions/nls.fish +++ b/.config/fish/functions/nls.fish @@ -1,3 +1,7 @@ function nls --wraps='npm list' --description 'alias nls=npm list' - npm list $argv + if type -f npm &>/dev/null + npm list $argv + else + missing_package npm + end end diff --git a/.config/fish/functions/nlsg.fish b/.config/fish/functions/nlsg.fish index fd17d0c7..1f887c43 100644 --- a/.config/fish/functions/nlsg.fish +++ b/.config/fish/functions/nlsg.fish @@ -1,3 +1,7 @@ function nlsg --wraps='npm list --global' --description 'alias nlsg=npm list --global' - npm list --global $argv + if type -f npm &>/dev/null + npm list --global $argv + else + missing_package npm + end end diff --git a/.config/fish/functions/nu.fish b/.config/fish/functions/nu.fish index 8d4b88cc..d97bf446 100644 --- a/.config/fish/functions/nu.fish +++ b/.config/fish/functions/nu.fish @@ -1,3 +1,7 @@ function nu --wraps='npm uninstall' --description 'alias nu=npm uninstall' - npm uninstall $argv + if type -f npm &>/dev/null + npm uninstall $argv + else + missing_package npm + end end diff --git a/.config/fish/functions/nud.fish b/.config/fish/functions/nud.fish index 22b2316a..59e513ee 100644 --- a/.config/fish/functions/nud.fish +++ b/.config/fish/functions/nud.fish @@ -1,3 +1,7 @@ function nud --wraps='npm uninstall --save-dev' --description 'alias nud=npm uninstall --save-dev' - npm uninstall --save-dev $argv + if type -f npm &>/dev/null + npm uninstall --save-dev $argv + else + missing_package npm + end end diff --git a/.config/fish/functions/nup.fish b/.config/fish/functions/nup.fish index 3fc25fee..37b76f3e 100644 --- a/.config/fish/functions/nup.fish +++ b/.config/fish/functions/nup.fish @@ -1,3 +1,7 @@ function nup --wraps='npm update' --description 'alias nup=npm update' - npm update $argv + if type -f npm &>/dev/null + npm update $argv + else + missing_package npm + end end diff --git a/.config/fish/functions/nus.fish b/.config/fish/functions/nus.fish index 2e829a1b..b5c8cd4d 100644 --- a/.config/fish/functions/nus.fish +++ b/.config/fish/functions/nus.fish @@ -1,3 +1,7 @@ function nus --wraps='npm uninstall --save' --description 'alias nus=npm uninstall --save' - npm uninstall --save $argv + if type -f npm &>/dev/null + npm uninstall --save $argv + else + missing_package npm + end end diff --git a/.config/fish/functions/pages.fish b/.config/fish/functions/pages.fish index 78fd1fa5..8d69720d 100644 --- a/.config/fish/functions/pages.fish +++ b/.config/fish/functions/pages.fish @@ -1,3 +1,7 @@ function pages --wraps=navi --description 'alias pages=navi' - navi $argv + if type -f navi &>/dev/null + navi $argv + else + missing_package navi + end end diff --git a/.config/fish/functions/proc.fish b/.config/fish/functions/proc.fish index f80795d8..dab02a6c 100644 --- a/.config/fish/functions/proc.fish +++ b/.config/fish/functions/proc.fish @@ -1,3 +1,7 @@ function proc --wraps=sysz --description 'alias proc=sysz' - sysz $argv + if type -f sysz &>/dev/null + sysz $argv + else + missing_package sysz + end end diff --git a/.config/fish/functions/pse.fish b/.config/fish/functions/pse.fish index 0815c5f0..ae660f0a 100644 --- a/.config/fish/functions/pse.fish +++ b/.config/fish/functions/pse.fish @@ -1,3 +1,8 @@ function pse --wraps=pacseek --description 'alias pse=pacseek' - pacseek $argv + if type -f pacseek &>/dev/null + pacseek $argv + else + missing_package pacseek + end + end diff --git a/.config/fish/functions/r.fish b/.config/fish/functions/r.fish index 2989aa3d..f924bd1e 100644 --- a/.config/fish/functions/r.fish +++ b/.config/fish/functions/r.fish @@ -1,3 +1,8 @@ function r --wraps='mise run' --description 'alias r=mise run' - mise run $argv + if type -f mise &>/dev/null + mise run $argv + else + missing_package mise + end + end diff --git a/.config/fish/functions/s.fish b/.config/fish/functions/s.fish index 4e120ce2..ca0eab0d 100644 --- a/.config/fish/functions/s.fish +++ b/.config/fish/functions/s.fish @@ -1,4 +1,3 @@ function s --wraps=sudo --description 'alias s=sudo' - sudo $argv - + sudo $argv end diff --git a/.config/fish/functions/t.fish b/.config/fish/functions/t.fish index 342118e0..60cdafc4 100644 --- a/.config/fish/functions/t.fish +++ b/.config/fish/functions/t.fish @@ -1,3 +1,7 @@ function t --wraps=tmux --description 'alias t=tmux' - tmux attach >/dev/null 2>&1 || tmux new-session $argv + if type -f tmux &>/dev/null + tmux attach >/dev/null 2>&1 || tmux new-session $argv + else + missing_package tmux + end end diff --git a/.config/fish/functions/ta.fish b/.config/fish/functions/ta.fish index 204ccef0..92db0056 100644 --- a/.config/fish/functions/ta.fish +++ b/.config/fish/functions/ta.fish @@ -1,3 +1,7 @@ function ta --wraps='tmux attach -t' --description 'alias ta=tmux attach -t' - tmux attach -t $argv + if type -f tmux &>/dev/null + tmux attach -t $argv + else + missing_package tmux + end end diff --git a/.config/fish/functions/v.fish b/.config/fish/functions/v.fish index 8ff68585..f1ee126e 100644 --- a/.config/fish/functions/v.fish +++ b/.config/fish/functions/v.fish @@ -1,3 +1,7 @@ function v --wraps=nvim --description 'alias v=nvim' - nvim $argv + if type -f nvim &>/dev/null + nvim $argv + else + missing_package nvim + end end diff --git a/.config/fish/functions/vcl.fish b/.config/fish/functions/vcl.fish index 5bb363d3..8fe0d753 100644 --- a/.config/fish/functions/vcl.fish +++ b/.config/fish/functions/vcl.fish @@ -1,3 +1,7 @@ function vcl --wraps='nvim --clean' --description 'alias vcl=nvim --clean' - nvim --clean $argv + if type -f nvim &>/dev/null + nvim --clean $argv + else + missing_package nvim + end end