config/shell/functions: enhance some aliases

This commit is contained in:
xeruf 2023-07-11 09:03:19 +02:00
parent 8e1f39e5bb
commit 71c3a77709
2 changed files with 16 additions and 16 deletions

View File

@ -67,7 +67,7 @@ sudos() {
}
resolvealias() {
alias "$1" 2>/dev/null | sed -n "s/$1='\?\(noglob \)\?\([-A-z]\+\)'\?\$/\2/p" | grep -m 1 . || echo $1
alias "$1" 2>/dev/null | sed -n "s|$1='\?\(noglob \)\?\([-A-z]\+\)'\?\$|\2|p" | grep -m 1 . || echo $1
}
h() {
@ -290,7 +290,8 @@ u() {
test "$result" = "y" && rm -rf "$DOOMLOCALDIR/straight" && doom sync -u
fi
pgrep emacsclient && echo -n "^ Emacs client processes. Press enter to restart the emacs server." && read
pkill --full "emacs --daemon" && emacs --daemon &
pkill --full "emacs --daemon"
tmux new-session -d -s emacs-daemon emacs --daemon
fi
else yadm l
sudo apt update && sudo apt upgrade
@ -384,7 +385,7 @@ alias grpc='grep --color=auto --line-number --binary-files=without-match --direc
alias grp='grpc --ignore-case'
# Grep recursively and paginate
# TODO remove some prefixes \([^ ]*/\)\?
grpr() { grp --color=always --recursive $(echo $DIRS_IGNORE | sed 's|-x |--exclude-dir |g') "$@" | less -FX; }
grpr() { grp --color=always --recursive '--exclude=*.sql' $(echo $DIRS_IGNORE | sed 's|-x |--exclude-dir |g') "$@" | less -FX; }
# Grep in shell config files
grsh() {
local search=$1
@ -481,19 +482,6 @@ killm() {
xargs --no-run-if-empty kill --verbose "${@:2}"
}
# Kil all Java processes except IDEA
# Pass "-9" to force-kill and "-q" to not output what has been killed
killJava() {
pgrep -f 'java' | while read id
do if [[ $(ps --no-headers -o cmd $id) != *"idea"* ]]; then
[[ "$@" == "-q" ]] || echo "killing $(ps -p $id -o pid,cmd --width 350 --no-headers)"
if [[ "$@" == "-9" ]]
then kill -9 $id
else kill $id
fi
fi; done
}
# Files {{{1
which exa >/dev/null &&
@ -518,6 +506,7 @@ compdef rcd=rsync
# TODO do not sync times to FAT
alias rc='rcs --links --hard-links --times'
alias rcu='rc --existing --size-only'
alias rcr='rcs --compress --size-only --times'
alias rcs='rsync --recursive --info=progress2,remove,symsafe,flist,del --human-readable'
alias dsync='rc --delete --specials'
alias move='rc --remove-source-files'

11
.local/bin/scripts/killjava Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh -e
# Kil all Java processes except IDEA
# Pass "-9" to force-kill and "-q" to not output what has been killed
pgrep -f 'java' | while read id
do if [[ $(ps --no-headers -o cmd $id) != *"idea"* ]]; then
[[ "$@" == "-q" ]] || echo "killing $(ps -p $id -o pid,cmd --width 350 --no-headers)"
if [[ "$@" == "-9" ]]
then kill -9 $id
else kill $id
fi
fi; done