From 6f74ff691b4c4773c4d45c28341eb24a8856e1cd Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 16 Sep 2016 23:37:45 +0300 Subject: [PATCH] .shellrc: make env-independent functions scripts --- .shellrc | 24 ------------------------ bin/KillAll | 12 ++++++++++++ bin/PWd | 2 ++ bin/Pwd | 2 ++ bin/pidOf | 4 ++++ bin/psg | 2 ++ bin/pswg | 2 ++ 7 files changed, 24 insertions(+), 24 deletions(-) create mode 100755 bin/KillAll create mode 100755 bin/PWd create mode 100755 bin/Pwd create mode 100755 bin/pidOf create mode 100755 bin/psg create mode 100755 bin/pswg diff --git a/.shellrc b/.shellrc index a11597f..b0d2afe 100644 --- a/.shellrc +++ b/.shellrc @@ -160,30 +160,6 @@ fi # clear history, clear screen and logout - - -#Pwd() { pwd | sed "s/.*\/\(.*\)\/\(.*\)\/\(.*\)\/\(.*\)/...\/\2\/\3\/\4/"; } -#PWd() { pwd | sed "s/.*\/\(.*\)\/\(.*\)/...\/\2/"; } - - -psg() { ps auxw | grep -i "$@" | grep -v '\(ps auxw\|grep\)'; } -pswg() { ps auxwww | grep -i "$@" | grep -v '\(ps auxw\|grep\)'; } - -# Like pgrep -f -pidOf() { ps auxwww | grep -i "$@" | grep -v '\(ps auxw\|grep\|pidOf\|KillAll\)' | awk '{print $2}'; } - -# A kind of pkill/killall -KillAll() { - if [ -z "$1" -o -n "$3" ]; then - echo "Usage: KillAll [-signal] proc_regexp" >&2 - return 1 - fi - if [ -z "$2" ]; then - kill `pidOf "$1"` - else - kill "$1" `pidOf "$2"` - fi -} #chlo() { cd; unset HISTFILE; rm -f .sh_history; history -c; clear; logout || exit; } diff --git a/bin/KillAll b/bin/KillAll new file mode 100755 index 0000000..92dbf74 --- /dev/null +++ b/bin/KillAll @@ -0,0 +1,12 @@ +#! /bin/sh + +# A kind of pkill/killall +if [ -z "$1" -o -n "$3" ]; then + echo "Usage: KillAll [-signal] proc_regexp" >&2 + return 1 +fi +if [ -z "$2" ]; then + kill `pidOf "$1"` +else + kill "$1" `pidOf "$2"` +fi diff --git a/bin/PWd b/bin/PWd new file mode 100755 index 0000000..d39e44e --- /dev/null +++ b/bin/PWd @@ -0,0 +1,2 @@ +#! /bin/sh +pwd | sed "s/.*\/\(.*\)\/\(.*\)/...\/\2/" diff --git a/bin/Pwd b/bin/Pwd new file mode 100755 index 0000000..ec6f821 --- /dev/null +++ b/bin/Pwd @@ -0,0 +1,2 @@ +#! /bin/sh +pwd | sed "s/.*\/\(.*\)\/\(.*\)\/\(.*\)\/\(.*\)/...\/\2\/\3\/\4/" diff --git a/bin/pidOf b/bin/pidOf new file mode 100755 index 0000000..bc7dd7a --- /dev/null +++ b/bin/pidOf @@ -0,0 +1,4 @@ +#! /bin/sh + +# Like pgrep -f +ps auxwww | grep -i "$@" | grep -v '\(ps auxw\|grep\|pidOf\|KillAll\)' | awk '{print $2}' diff --git a/bin/psg b/bin/psg new file mode 100755 index 0000000..86dc037 --- /dev/null +++ b/bin/psg @@ -0,0 +1,2 @@ +#! /bin/sh +ps auxw | grep -i "$@" | grep -v '\(ps auxw\|grep\|psg\)' diff --git a/bin/pswg b/bin/pswg new file mode 100755 index 0000000..2960da5 --- /dev/null +++ b/bin/pswg @@ -0,0 +1,2 @@ +#! /bin/sh +ps auxwww | grep -i "$@" | grep -v '\(ps auxw\|grep\|pswg\)' -- 2.39.2