2023-02-04 12:45:02 +02:00
|
|
|
# Fuck default aliases
|
|
|
|
unalias -a
|
|
|
|
|
2024-11-11 12:21:02 +02:00
|
|
|
function testbin { whence $@ > /dev/null }
|
2023-02-04 12:45:02 +02:00
|
|
|
|
2024-11-11 12:21:02 +02:00
|
|
|
function termcompat {
|
2022-08-23 10:55:20 +03:00
|
|
|
typeset term=$TERM
|
|
|
|
case $term in
|
|
|
|
(alacritty*) ;&
|
|
|
|
(kitty*) ;&
|
2022-12-21 17:59:58 +02:00
|
|
|
(wezterm) ;&
|
2022-08-23 10:55:20 +03:00
|
|
|
(xterm-*)
|
|
|
|
term=xterm;;
|
|
|
|
(rxvt-unicode*)
|
|
|
|
term=rxvt-unicode;;
|
|
|
|
(tmux*)
|
|
|
|
term=screen.xterm-new;;
|
|
|
|
esac
|
|
|
|
TERM=$term command $@
|
|
|
|
}
|
2022-08-19 22:37:17 +03:00
|
|
|
|
2024-11-11 12:21:02 +02:00
|
|
|
function addpath {
|
2022-09-24 16:15:54 +03:00
|
|
|
typeset newpath=$1
|
|
|
|
if [[ ! $PATH =~ $newpath ]]; then
|
|
|
|
PATH+=:$newpath
|
|
|
|
export PATH
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-11-11 12:21:02 +02:00
|
|
|
function fsf {
|
2022-09-03 19:30:19 +03:00
|
|
|
typeset host prompt="SSH Remote > "
|
|
|
|
host=$(cut -d\ -f1 $HOME/.ssh/known_hosts | sort -u | fzf --prompt=$prompt) || return 1
|
|
|
|
|
|
|
|
termcompat ssh $host $@
|
|
|
|
}
|
|
|
|
|
2024-11-11 12:21:02 +02:00
|
|
|
function beep { printf $'\007' }
|
|
|
|
function fixterm { printf $'\u001bc' }
|
2022-08-19 22:37:17 +03:00
|
|
|
|
2024-11-11 12:21:02 +02:00
|
|
|
function diff { command diff --color $@ }
|
|
|
|
function tailf { command less +F $@ }
|
|
|
|
function grep { command grep --color=auto $@ }
|
|
|
|
function rgrep { grep --exclude-dir=.git -R $@ }
|
|
|
|
function s { termcompat ssh $@ }
|
2022-08-19 22:37:17 +03:00
|
|
|
|
2024-11-11 12:21:02 +02:00
|
|
|
function tmux { command tmux -2 $@ }
|
|
|
|
function atmux { tmux attach || tmux }
|
2023-02-04 12:45:02 +02:00
|
|
|
|
2024-11-11 12:21:02 +02:00
|
|
|
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 }
|
2022-08-19 22:37:17 +03:00
|
|
|
|
2024-11-11 12:21:02 +02:00
|
|
|
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 {
|
2022-08-19 22:37:17 +03:00
|
|
|
echo "OK to reset and clean teh repo?"
|
|
|
|
read -sq _
|
|
|
|
(( $? )) && return 1
|
2023-02-04 14:51:00 +02:00
|
|
|
command git clean -fd
|
|
|
|
command git reset --hard
|
2022-08-19 22:37:17 +03:00
|
|
|
}
|
2022-09-03 19:30:19 +03:00
|
|
|
|
2023-02-04 12:45:02 +02:00
|
|
|
if testbin diff-so-fancy; then
|
2024-11-11 12:21:02 +02:00
|
|
|
function gdf { gdiff $@ | command diff-so-fancy | command less --tabs=4 -RSFX }
|
2022-08-19 22:37:17 +03:00
|
|
|
else
|
2024-11-11 12:21:02 +02:00
|
|
|
function gdf { gdiff $@ }
|
2022-08-19 22:37:17 +03:00
|
|
|
fi
|
|
|
|
|
2023-09-14 19:35:13 +03:00
|
|
|
if testbin eza; then
|
2024-11-11 12:21:02 +02:00
|
|
|
function ls { command eza --group-directories-first $@ }
|
|
|
|
function ll { ls -alg $@ }
|
|
|
|
function ld { ls -dlg $@ }
|
2022-08-23 10:55:20 +03:00
|
|
|
else
|
2024-11-11 12:21:02 +02:00
|
|
|
function ls { command ls --color=auto --group-directories-first $@ }
|
|
|
|
function ll { ls -alh $@ }
|
|
|
|
function ld { ls -dlh $@ }
|
2022-08-23 10:55:20 +03:00
|
|
|
fi
|
2022-08-22 18:25:37 +03:00
|
|
|
|
2022-08-19 22:37:17 +03:00
|
|
|
# grc
|
2023-02-04 12:45:02 +02:00
|
|
|
if testbin grc; then
|
2022-08-19 22:37:17 +03:00
|
|
|
cmds=(\
|
|
|
|
cc configure cvs df dig gcc gmake id ip last lsof make mount \
|
|
|
|
mtr netstat ping ping6 ps tcpdump traceroute traceroute6 \
|
|
|
|
)
|
2024-05-14 11:26:46 +03:00
|
|
|
for cmd in $cmds; do
|
2024-11-11 12:21:02 +02:00
|
|
|
eval "function $cmd { command grc -es --colour=auto $cmd \$@ }"
|
2022-08-19 22:37:17 +03:00
|
|
|
done
|
|
|
|
unset cmds cmd
|
|
|
|
fi
|