From 74602e8d8dc1fc51e1c2c18423f4c43ed55d1fea Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Tue, 18 Feb 2020 21:22:29 +0100 Subject: [PATCH] implemented poor man's pkill --- .tmux.conf | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index 567db7f..f9a2ed5 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -209,6 +209,33 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # printf '%s' "$*" | perl -CS -pe 's/(\\u([0-9A-Fa-f]{1,4})|\\U([0-9A-Fa-f]{1,8}))/chr(hex($2.$3))/eg' 2>/dev/null # } # +# if command -v pkill > /dev/null 2>&1; then +# _pkillf() { +# pkill -f "$@" || true +# } +# else +# case "$_uname_s" in +# *CYGWIN*) +# _pkillf() { +# while IFS= read -r pid; do +# kill "$pid" || true +# done << EOF +# $(grep -Eao "$@" /proc/*/cmdline | xargs -0 | sed -E -n 's,/proc/([0-9]+)/.+$,\1,pg') +# EOF +# } +# ;; +# *) +# _pkillf() { +# while IFS= read -r pid; do +# kill "$pid" || true +# done << EOF +# $(ps -x -o pid= -o command= | grep -E "$@" | cut -d' ' -f1) +# EOF +# } +# ;; +# esac +# fi +# # _maximize_pane() { # current_session=${1:-$(tmux display -p '#{session_name}')} # current_pane=${2:-$(tmux display -p '#{pane_id}')} @@ -1079,7 +1106,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # tmux_conf_battery_status_charging=$(_decode_unicode_escapes "${tmux_conf_battery_status_charging:-↑}") # U+2191 # tmux_conf_battery_status_discharging=$(_decode_unicode_escapes "${tmux_conf_battery_status_discharging:-↓}") # U+2193 # -# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _battery_bar' || true +# _pkillf 'cut -c3- ~/\.tmux\.conf \| sh -s _battery_bar' # _battery_info # if [ "$charge" != 0 ]; then # case "$status_left $status_right" in @@ -1118,7 +1145,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ;; # esac # -# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _uptime' || true +# _pkillf 'cut -c3- ~/\.tmux\.conf \| sh -s _uptime' # case "$status_left $status_right" in # *'#{uptime_d}'*|*'#{uptime_h}'*|*'#{uptime_m}'*|*'#{uptime_s}'*) # status_left=$(echo "$status_left" | sed -E \ @@ -1145,7 +1172,7 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim # ;; # esac # -# pkill -f 'cut -c3- ~/\.tmux\.conf \| sh -s _loadavg' || true +# _pkillf 'cut -c3- ~/\.tmux\.conf \| sh -s _loadavg' # case "$status_left $status_right" in # *'#{loadavg}'*) # status_left=$(echo "$status_left" | sed -E \