From 71c3a77709444e54a8a7442c4ab04cbcc7cc7309 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 11 Jul 2023 09:03:19 +0200 Subject: [PATCH] config/shell/functions: enhance some aliases --- .config/shell/functions | 21 +++++---------------- .local/bin/scripts/killjava | 11 +++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) create mode 100755 .local/bin/scripts/killjava diff --git a/.config/shell/functions b/.config/shell/functions index 5b18354..8dffdd8 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -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' diff --git a/.local/bin/scripts/killjava b/.local/bin/scripts/killjava new file mode 100755 index 0000000..f10bce7 --- /dev/null +++ b/.local/bin/scripts/killjava @@ -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