]> git.phdru.name Git - dotfiles.git/commitdiff
.shellrc: make env-independent functions scripts
authorOleg Broytman <phd@phdru.name>
Fri, 16 Sep 2016 20:37:45 +0000 (23:37 +0300)
committerOleg Broytman <phd@phdru.name>
Fri, 16 Sep 2016 20:37:45 +0000 (23:37 +0300)
.shellrc
bin/KillAll [new file with mode: 0755]
bin/PWd [new file with mode: 0755]
bin/Pwd [new file with mode: 0755]
bin/pidOf [new file with mode: 0755]
bin/psg [new file with mode: 0755]
bin/pswg [new file with mode: 0755]

index a11597f3a8c24ba0bec7cdce8b132f1ec8b2d4b2..b0d2afe47dff8499c398e33dec46aad25bc3cc78 100644 (file)
--- 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 (executable)
index 0000000..92dbf74
--- /dev/null
@@ -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 (executable)
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 (executable)
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 (executable)
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 (executable)
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 (executable)
index 0000000..2960da5
--- /dev/null
+++ b/bin/pswg
@@ -0,0 +1,2 @@
+#! /bin/sh
+ps auxwww | grep -i "$@" | grep -v '\(ps auxw\|grep\|pswg\)'