Permalink
Browse files

GitHub status indicator in tmux status line

  • Loading branch information...
pengwynn committed Oct 15, 2013
1 parent 12dd482 commit ee35bfe920f214c2785eea85ea8447308a0f2733
Showing with 54 additions and 0 deletions.
  1. +25 −0 agents/fm.wynn.tmux-github-status.plist
  2. +29 −0 bin/tmux-github-status
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>fm.wynn.tmux-github-status</string>
<key>StartInterval</key>
<integer>60</integer>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/Users/wynn/.dotfiles/bin/tmux-github-status</string>
</array>
<key>KeepAlive</key>
<true/>
<key>UserName</key>
<string>wynn</string>
</dict>
</plist>
View
@@ -0,0 +1,29 @@
#!/bin/sh
set -e
INDICATOR=""
CURRENT_STATUS=$(tmux show-options | grep status-left-fg | grep -Eio '(red|green|yellow)')
STATUS_URL="https://status.github.com/api"
GITHUB_STATUS=$(curl $STATUS_URL/status.json | jq -r '.status')
case $GITHUB_STATUS in
major)
NEW_STATUS="red" ;;
minor)
NEW_STATUS="yellow" ;;
*)
NEW_STATUS="green";;
esac
tmux set-option status-left-fg $NEW_STATUS
tmux set-option status-left "$INDICATOR"
if [ "$NEW_STATUS" != "$CURRENT_STATUS" ]; then
MESSAGE="$(curl $STATUS_URL/last-message.json | jq -r '.body')"
tmux set-option message-bg $NEW_STATUS
tmux display-message " $MESSAGE"
# make sure message exits first
sleep 5
tmux set-option -u message-bg
tmux set-option -u message-fg
fi

7 comments on commit ee35bfe

@pengwynn

This comment has been minimized.

Show comment
Hide comment
@pengwynn

pengwynn Oct 15, 2013

Owner

Shows green, yellow, red for good, minor, major statuses.
screen shot 2013-10-14 at 7 13 15 pm
Displays a message on status change.
screen shot 2013-10-14 at 7 12 47 pm

Owner

pengwynn replied Oct 15, 2013

Shows green, yellow, red for good, minor, major statuses.
screen shot 2013-10-14 at 7 13 15 pm
Displays a message on status change.
screen shot 2013-10-14 at 7 12 47 pm

@adamyonk

This comment has been minimized.

Show comment
Hide comment
@adamyonk

adamyonk Oct 15, 2013

Contributor

I like it! So this happens in every session, right?

Contributor

adamyonk replied Oct 15, 2013

I like it! So this happens in every session, right?

@pengwynn

This comment has been minimized.

Show comment
Hide comment
@pengwynn

pengwynn Oct 15, 2013

Owner

Currently only in the active session. You can set it globally for all sessions with the -g flag, but you'll have to do a source-file on your config to revert to default colors since you can't unset global options.

Owner

pengwynn replied Oct 15, 2013

Currently only in the active session. You can set it globally for all sessions with the -g flag, but you'll have to do a source-file on your config to revert to default colors since you can't unset global options.

@mislav

This comment has been minimized.

Show comment
Hide comment
@mislav

mislav Oct 15, 2013

Contributor

Neat. I would rather that the script ran at an interval writes to a status file, and then tmux status line reads from that file (at its own interval). That avoids the script having to directly interface with tmux. But that also means that you don't get to tmux display-message.

Contributor

mislav replied Oct 15, 2013

Neat. I would rather that the script ran at an interval writes to a status file, and then tmux status line reads from that file (at its own interval). That avoids the script having to directly interface with tmux. But that also means that you don't get to tmux display-message.

@adamyonk

This comment has been minimized.

Show comment
Hide comment
@adamyonk

adamyonk Oct 15, 2013

Contributor

But, that may open up better possibilities as far as reading multiple service statuses at once. GitHub, Heroku, AWS, et cetera.

Contributor

adamyonk replied Oct 15, 2013

But, that may open up better possibilities as far as reading multiple service statuses at once. GitHub, Heroku, AWS, et cetera.

@pengwynn

This comment has been minimized.

Show comment
Hide comment
@pengwynn

pengwynn Oct 15, 2013

Owner

Yeah I went this way primarily for display-message and a cleaner separation from other scripts that notify tmux like Guard's notifier.

Owner

pengwynn replied Oct 15, 2013

Yeah I went this way primarily for display-message and a cleaner separation from other scripts that notify tmux like Guard's notifier.

@mislav

This comment has been minimized.

Show comment
Hide comment
@mislav

mislav Oct 15, 2013

Contributor

@adamyonk: Good idea. For me, an ideal tmux status would be nothing (blank) is everything is up an running, or a yellow/red name of the service that's currently down.

Contributor

mislav replied Oct 15, 2013

@adamyonk: Good idea. For me, an ideal tmux status would be nothing (blank) is everything is up an running, or a yellow/red name of the service that's currently down.

Please sign in to comment.