-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Fixes bug #7 which allowed for multiple simultaneous pane monitoring
- Loading branch information
Showing
4 changed files
with
90 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,34 @@ | ||
#!/usr/bin/env bash | ||
## -- Cancel monitoring script | ||
# Used to cancel the current pane monitor job | ||
|
||
# get id of the current active pane | ||
PANEID=$(tmux list-panes | grep "active" | awk -F\] '{print $3}' | awk '{print $1}') | ||
PID_DIR=~/.tmux/notify | ||
# Get current directory | ||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
# Source helpers and variables | ||
source "$CURRENT_DIR/helpers.sh" | ||
source "$CURRENT_DIR/variables.sh" | ||
|
||
# Get pane id | ||
SESSION_NR=$(tmux list-sessions | grep "(attached)" | awk '{print $1}' | tr -d :) | ||
WINDOW_NR=$(tmux list-windows | grep "(active)" | awk '{print $1}' | tr -d :) | ||
PANE_NR=$(tmux list-panes | grep "active" | awk -F\] '{print $3}' | awk '{print $1}' | tr -d %) | ||
PANE_ID=$(detox_file_name "s_${SESSION_NR}_w${WINDOW_NR}_p${PANE_NR}") | ||
|
||
# Cancel monitor process if active | ||
{ # Try | ||
|
||
# consult pid file for the pid | ||
PID=$(cat "$PID_DIR/$PANEID".pid) | ||
# Consult pid file for the pid | ||
PID=$(cat "${PID_DIR}/${PANE_ID}.pid") | ||
|
||
# job done - kill process and remove pid file | ||
kill $PID | ||
rm "${PID_DIR}/${PANE_ID}.pid" | ||
|
||
# job done - kill process and remove pid file | ||
kill $PID | ||
rm "$PID_DIR/$PANEID".pid | ||
# Display success message | ||
tmux display-message "Pane monitoring canceled..." | ||
|
||
} || { # Catch | ||
tmux display-message "Pane not monitored..." | ||
exit 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters