Skip to content

Commit 067fdd8

Browse files
committed
feat: add the tnotify-prompt-regex option
1 parent b713320 commit 067fdd8

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

scripts/notify.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,17 @@ if [[ ! -f "$PID_FILE_PATH" ]]; then # If pane not yet monitored
4646
complete_message="Tmux pane task completed!"
4747
fi
4848

49-
# Create bash suffix list
50-
# NOTE: Looks complicated but uses shell parameter expansion
51-
# see https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Shell-Parameter-Expansion
52-
prompt_suffixes="$(get_tmux_option "$prompt_suffixes" "$prompt_suffixes_default")"
53-
prompt_suffixes=${prompt_suffixes// /} # Remove whitespace
54-
prompt_suffixes=${prompt_suffixes//,/|} # Replace comma with or operator
55-
prompt_suffixes=$(escape_glob_chars "$prompt_suffixes")
56-
prompt_suffixes="\(${prompt_suffixes}\)$"
49+
prompt_regex="$(get_tmux_option "$prompt_regex" "$prompt_regex_default")"
50+
if [[ -z "$prompt_regex" ]]; then
51+
# Create bash suffix list
52+
# NOTE: Looks complicated but uses shell parameter expansion
53+
# see https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Shell-Parameter-Expansion
54+
prompt_regex="$(get_tmux_option "$prompt_suffixes" "$prompt_suffixes_default")"
55+
prompt_regex=${prompt_regex// /} # Remove whitespace
56+
prompt_regex=${prompt_regex//,/|} # Replace comma with or operator
57+
prompt_regex=$(escape_glob_chars "$prompt_regex")
58+
prompt_regex="\(${prompt_regex}\)$"
59+
fi
5760

5861
# Check process status every 10 seconds to see if has is finished
5962
while true; do
@@ -62,7 +65,7 @@ if [[ ! -f "$PID_FILE_PATH" ]]; then # If pane not yet monitored
6265

6366
# run tests to determine if work is done
6467
# if so, break and notify
65-
if echo "$output" | tail -n2 | grep -e $prompt_suffixes &> /dev/null; then
68+
if echo "$output" | tail -n2 | grep -e $prompt_regex &> /dev/null; then
6669
# tmux display-message "$@"
6770
if [[ "$1" == "true" ]]; then
6871
tmux switch -t \$"$SESSION_ID"

scripts/variables.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export PID_FILE_PATH="${PID_DIR}/${PANE_ID}.pid"
1717
## Tnotify tmux options
1818
export prompt_suffixes="@tnotify-prompt-suffixes"
1919
export prompt_suffixes_default="$,#,%"
20+
export prompt_regex="@tnotify-prompt-regex"
21+
export prompt_regex=""
2022
export custom_notify_command="@tnotify-custom-cmd"
2123
export custom_notify_command_default="bash ~/Desktop/test.bash"
2224

0 commit comments

Comments
 (0)