2023-02-04 12:45:02 +02:00
|
|
|
# Fuck default aliases
|
|
|
|
unalias -a
|
|
|
|
|
|
|
|
testbin() { whence $@ > /dev/null }
|
|
|
|
|
2022-08-23 10:55:20 +03:00
|
|
|
termcompat() {
|
|
|
|
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
|
|
|
|
2022-09-24 16:15:54 +03:00
|
|
|
addpath() {
|
|
|
|
typeset newpath=$1
|
|
|
|
if [[ ! $PATH =~ $newpath ]]; then
|
|
|
|
PATH+=:$newpath
|
|
|
|
export PATH
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-09-03 19:30:19 +03:00
|
|
|
fsf() {
|
|
|
|
typeset host prompt="SSH Remote > "
|
|
|
|
host=$(cut -d\ -f1 $HOME/.ssh/known_hosts | sort -u | fzf --prompt=$prompt) || return 1
|
|
|
|
|
|
|
|
termcompat ssh $host $@
|
|
|
|
}
|
|
|
|
|
2022-08-19 22:37:17 +03:00
|
|
|
beep() { printf $'\007' }
|
|
|
|
fixterm() { printf $'c' }
|
|
|
|
|
2022-08-23 10:55:20 +03:00
|
|
|
diff() { command diff --color $@ }
|
|
|
|
tailf() { command less +F $@ }
|
2023-02-06 18:04:03 +02:00
|
|
|
grep() { command grep --color=auto $@ }
|
2023-02-05 22:45:38 +02:00
|
|
|
rgrep() { grep --exclude-dir=.git -R $@ }
|
2022-08-23 10:55:20 +03:00
|
|
|
s() { termcompat ssh $@ }
|
2022-08-19 22:37:17 +03:00
|
|
|
|
2023-02-04 12:45:02 +02:00
|
|
|
if testbin nvim; then
|
|
|
|
vi() { command nvim $@ }
|
|
|
|
vim() { command nvim $@ }
|
|
|
|
fi
|
|
|
|
|
2022-08-23 10:55:20 +03:00
|
|
|
tmux() { command tmux -2 $@ }
|
|
|
|
atmux() { tmux attach || tmux }
|
2022-08-19 22:37:17 +03:00
|
|
|
|
2023-02-04 12:45:02 +02:00
|
|
|
g() { command lazygit $@ }
|
2022-08-23 10:55:20 +03:00
|
|
|
gci() { command git commit $@ }
|
|
|
|
gsl() { command git stash list $@ }
|
|
|
|
gss() { command git status -sbu $@ }
|
2022-10-25 12:53:28 +03:00
|
|
|
gsw() { command git switch $@ }
|
2022-08-23 10:55:20 +03:00
|
|
|
gup() { command git pull $@ }
|
2023-02-05 22:45:38 +02:00
|
|
|
gwta() { command git worktree add $@ }
|
2023-02-10 19:04:47 +02:00
|
|
|
gwtp() { command git worktree prune -v }
|
2023-02-05 22:45:38 +02:00
|
|
|
groot() { cd $(command git rev-parse --show-toplevel) || return 0 }
|
2022-08-23 10:55:20 +03:00
|
|
|
gdiff() { command git diff --color $@; }
|
|
|
|
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
|
2022-08-19 22:37:17 +03:00
|
|
|
gdf() { gdiff $@ | command diff-so-fancy | command less --tabs=4 -RSFX }
|
|
|
|
else
|
|
|
|
gdf() { gdiff $@ }
|
|
|
|
fi
|
|
|
|
|
2023-09-14 19:35:13 +03:00
|
|
|
if testbin eza; then
|
|
|
|
ls() { command eza --icons --group-directories-first $@ }
|
2022-08-23 10:55:20 +03:00
|
|
|
ll() { ls -alg $@ }
|
|
|
|
ld() { ls -dlg $@ }
|
|
|
|
else
|
|
|
|
ls() { command ls --color=auto --group-directories-first $@ }
|
|
|
|
ll() { ls -alh $@ }
|
|
|
|
ld() { ls -dlh $@ }
|
|
|
|
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 \
|
|
|
|
)
|
|
|
|
for cmd in $cmds[@]; do
|
|
|
|
alias $cmd="command grc -es --colour=auto $cmd"
|
|
|
|
done
|
|
|
|
unset cmds cmd
|
|
|
|
fi
|