Skip to content

Instantly share code, notes, and snippets.

@jart
Created October 10, 2013 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jart/6912644 to your computer and use it in GitHub Desktop.
Save jart/6912644 to your computer and use it in GitHub Desktop.
GNU Screen Bitcoin Ticker
## GNU Screen Configuration
## Justine Tunney <jtunney@gmail.com>
# GNU Screen + this config allow you to:
#
# - Have tabs inside your terminal.
#
# - Have your terminal sessions persist, even if you close your ssh connection.
# This is especially great if you hop between multiple computers or simply
# don't want to lose what you're working on.
#
# - Allow multiple clients (or humans) to view and edit the same terminal
# session simultaneously (sort of like remote desktop).
#
# - Bitcoin MtGox BTC/USD Ticker!
#
# This config has been battle tested across many platforms, terminal programs,
# and operating systems. It supports 256-color and doesn't screw anything up.
# It displays a pretty status bar at the bottom of your terminal so you can
# keep track of where you are. It's just awesome, ok?
################################################################################
## GETTING STARTED
# Shell Commands:
#
# screen -DR <- start new screen session (or attach to existing)
# screen -X <- attach and allow others to share your screen
#
# Shortcuts (they all start with backtic: `)
#
# ` `: Type a normal backtic (by pressing it twice)
# ` d: Detach and exit screen (screen -DR brings it back)
# ` n: Go to Next tab
# ` p: Go to Previous tab
# ` k: Kill current tab
# ` A: Change title of current tab
# ` [: Freezes screen so you can use the arrow keys to scroll around and
# look for information. Press '?' to start searching backwards
# and `/` to search forward (vi shortcuts). You can also use the
# scroll wheel. Press <enter> a bunch of times to exit this mode.
################################################################################
## GENERAL CONFIGURATION
escape `` # this makes back-tic (under tilde) the magic key
# escape ^x^x # uncomment me if you'd prefer C-x
# escape ^a^a # C-a is actually the default. What were they thinking?
autodetach on
vbell on
vbell_msg "~~OH SNAP~~"
startup_message off
shelltitle "$|bash"
# bind ^w windowlist -m
# bind w windowlist -m
bind ^n next
bind n next
bind ^h prev
bind h prev
bind ^t focus
bind t focus
bind ^r title
bind ^m colon
bind 0 remove
bind 1 only
bind 2 split
bind = resize =
bind + resize +3
bind - resize -3
backtick 1 60 60 /home/jart/bin/mtgox
caption always "%{= KW}%-w%{= wk}%50>%n %t%{-}%+w%< %=[%1` BTC/USD | %H | %l | %D %C %a]"
hardstatus off
################################################################################
## XTERM TWEAKS
# These are very important if you want emacs keyboard shortcuts to
# behave normally.
#xterm understands both im/ic and doesn't have a status line.
#Note: Do not specify im and ic in the real termcap/info file as
#some programs (e.g. vi) will not work anymore.
termcap xterm hs@:cs=\E[%i%d;%dr:im=\E[4h:ei=\E[4l
terminfo xterm hs@:cs=\E[%i%p1%d;%p2%dr:im=\E[4h:ei=\E[4l
#80/132 column switching must be enabled for ^AW to work
#change init sequence to not switch width
termcapinfo xterm Z0=\E[?3h:Z1=\E[?3l:is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l
#defscrollback 5000
# Make the output buffer large for (fast) xterms.
termcapinfo xterm* OL=10000
# tell screen that xterm can switch to dark background and has function
# keys.
termcapinfo xterm 'VR=\E[?5h:VN=\E[?5l'
termcapinfo xterm 'k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~'
termcapinfo xterm 'kh=\E[1~:kI=\E[2~:kD=\E[3~:kH=\E[4~:kP=\E[H:kN=\E[6~'
# special xterm hardstatus: use the window title.
termcapinfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]0;screen\007'
# our xterm has colors! (rxvt, too)
termcap xterm 'AF=\E[3%dm:AB=\E[4%dm'
terminfo xterm 'AF=\E[3%p1%dm:AB=\E[4%p1%dm'
#terminfo xterm 'vb=\E[?5h$<200/>\E[?5l'
termcapinfo xterm 'vi=\E[?25l:ve=\E[34h\E[?25h:vs=\E[34l'
# emulate part of the 'K' charset
termcapinfo xterm 'XC=K%,%\E(B,[\304,\\\\\326,]\334,{\344,|\366,}\374,~\337'
# Support 256-color mode.
attrcolor b ".I"
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
defbce "on"
# ProTip: Run `crontab -e`
SHELL=/bin/bash
USER=jart
HOME=/home/jart
*/5 * * * * ~/bin/mtgox.cron
#!/bin/sh
# Don't forget to `chmod +x ~/bin/mtgox` me!
cat /tmp/mtgox
#!/bin/sh
# Don't forget to `chmod +x ~/bin/mtgox.cron` me!
curl -s http://data.mtgox.com/api/1/BTCUSD/ticker 2> /dev/null \
| python -c "import sys, json; print json.load(sys.stdin)['return']['last']['display']" \
> /tmp/mtgox.tmp 2> /dev/null \
&& mv /tmp/mtgox.tmp /tmp/mtgox
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment