Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions scripts/notify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,17 @@ if [[ ! -f "$PID_FILE_PATH" ]]; then # If pane not yet monitored
complete_message="Tmux pane task completed!"
fi

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

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

# run tests to determine if work is done
# if so, break and notify
if echo "$output" | tail -n2 | grep -e $prompt_suffixes &> /dev/null; then
if echo "$output" | tail -n2 | grep -e $prompt_regex_value &> /dev/null; then
# tmux display-message "$@"
if [[ "$1" == "true" ]]; then
tmux switch -t \$"$SESSION_ID"
Expand Down
2 changes: 2 additions & 0 deletions scripts/variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export PID_FILE_PATH="${PID_DIR}/${PANE_ID}.pid"
## Tnotify tmux options
export prompt_suffixes="@tnotify-prompt-suffixes"
export prompt_suffixes_default="$,#,%"
export prompt_regex="@tnotify-prompt-regex"
export prompt_regex_default=""
export custom_notify_command="@tnotify-custom-cmd"
export custom_notify_command_default="bash ~/Desktop/test.bash"

Expand Down