From 4968bf18ac223ef90480fe8f6eff952c5026cef5 Mon Sep 17 00:00:00 2001 From: Von Random Date: Thu, 16 Oct 2025 19:56:23 +0300 Subject: [PATCH] zsh: fix syntax highlight in editors, create grc functions only when they will work --- dot_config/zsh/functions.zsh | 66 ++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/dot_config/zsh/functions.zsh b/dot_config/zsh/functions.zsh index a590929..c08cfd6 100644 --- a/dot_config/zsh/functions.zsh +++ b/dot_config/zsh/functions.zsh @@ -9,34 +9,34 @@ function addpath { fi } -function testbin { whence $@ > /dev/null } +function testbin { whence $@ > /dev/null; } -function cm { command chezmoi $@ } -function diff { command diff --color $@ } -function tailf { command less +F $@ } -function grep { command grep --color=auto $@ } -function rgrep { grep --exclude-dir=.git -R $@ } -function zj { command zellij $@ } +function cm { command chezmoi $@; } +function diff { command diff --color $@; } +function tailf { command less +F $@; } +function grep { command grep --color=auto $@; } +function rgrep { grep --exclude-dir=.git -R $@; } +function zj { command zellij $@; } -function tmux { command tmux -2 $@ } -function atmux { tmux attach || tmux } +function tmux { command tmux -2 $@; } +function atmux { tmux attach || tmux; } -function ksw { command kubecm switch $@ } -function k { command kubectl $@ } -function kg { command kubectl get $@ } -function kc { command kubectl config $@ } -function kshell { command kubectl exec -n $1 --stdin --tty $2 -- /bin/sh } +function ksw { command kubecm switch $@; } +function k { command kubectl $@; } +function kg { command kubectl get $@; } +function kc { command kubectl config $@; } +function kshell { command kubectl exec -n $1 --stdin --tty $2 -- /bin/sh; } -function g { command lazygit $@ } -function gci { command git commit $@ } -function gsl { command git stash list $@ } -function gss { command git status -sbu $@ } -function gsw { command git switch $@ } -function gup { command git pull $@ } -function gwta { command git worktree add $@ } -function gwtp { command git worktree prune -v } -function groot { cd $(command git rev-parse --show-toplevel) || return 0 } -function gdiff { command git diff --color $@ } +function g { command lazygit $@; } +function gci { command git commit $@; } +function gsl { command git stash list $@; } +function gss { command git status -sbu $@; } +function gsw { command git switch $@; } +function gup { command git pull $@; } +function gwta { command git worktree add $@; } +function gwtp { command git worktree prune -v; } +function groot { cd $(command git rev-parse --show-toplevel) || return 0; } +function gdiff { command git diff --color $@; } function greset { echo "OK to reset and clean teh repo?" read -sq _ @@ -46,19 +46,19 @@ function greset { } if testbin diff-so-fancy; then - function gdf { gdiff $@ | command diff-so-fancy | command less --tabs=4 -RSFX } + function gdf { gdiff $@ | command diff-so-fancy | command less --tabs=4 -RSFX; } else - function gdf { gdiff $@ } + function gdf { gdiff $@; } fi if testbin eza; then - function ls { command eza --icons --group-directories-first $@ } - function ll { ls -alg $@ } - function ld { ls -dlg $@ } + function ls { command eza --icons --group-directories-first $@; } + function ll { ls -alg $@; } + function ld { ls -dlg $@; } else - function ls { command ls --color=auto --group-directories-first $@ } - function ll { ls -alh $@ } - function ld { ls -dlh $@ } + function ls { command ls --color=auto --group-directories-first $@; } + function ll { ls -alh $@; } + function ld { ls -dlh $@; } fi # grc @@ -73,7 +73,7 @@ if testbin grc; then dig diff df blkid ) for cmd in $cmds; do - eval "function $cmd { command grc -es --colour=auto $cmd \$@ }" + testbin $cmd && eval "function $cmd { command grc -es --colour=auto $cmd \$@; }" done unset cmds cmd fi