Skip to content

Instantly share code, notes, and snippets.

@thewtex
Created February 17, 2013 02:13
Show Gist options
  • Save thewtex/4969741 to your computer and use it in GitHub Desktop.
Save thewtex/4969741 to your computer and use it in GitHub Desktop.
Script to send a tmux, desktop, and audio notification after the completion of the given command when using tmux.
#!/bin/bash
# Send a tmux, desktop, and audio notification after the completion
# of the given command when using tmux.
#
# Requires: tmux
# Recommended: espeak, libnotify
tmux_window=$(/usr/bin/tmux list-windows \
-F "#{window_active} #{window_index} #{window_name}" | \
sort | tail -n 1 | cut -d ' ' -f 2-)
notification="$@ in ${tmux_window}"
"$@"
if test $? -eq 0; then
notification="${notification} succeeded"
else
notification="${notification} failed"
fi
/usr/bin/tmux display-message "${notification}"
if which notify-send &> /dev/null; then
notify-send "${notification}"
fi
if which espeak &> /dev/null; then
espeak "${notification}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment