tmux-golden-apple

pomodoro timer tmux plugin
git clone git://git.pyratebeard.net/tmux-golden-apple.git
Log | Files | Refs | README | LICENSE

golden_apple.tmux (736B)


      1 #!/usr/bin/env bash
      2 
      3 CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
      4 
      5 timer="#(${CURRENT_DIR}/scripts/timer.sh)"
      6 interpolate_string="\#{goldenapple}"
      7 
      8 interpolate() {
      9 	local -r status="${1}"
     10 	local -r status_value=$(tmux show-option -gqv "${status}")
     11 	tmux set-option -gq "${status}" "${status_value/$interpolate_string/$timer}"
     12 }
     13 
     14 timer() {
     15 	interpolate "status-left"
     16 	interpolate "status-right"
     17 }
     18 
     19 killtimer() {
     20 	for p in $(pgrep "${CURRENT_DIR}"/scripts/timer.sh | grep -v grep | awk '{print $2}') ; do
     21 		kill -9 "${p}"
     22 	done
     23 	tmux source-file ~/.tmux.conf >/dev/null 2>&1
     24 }
     25 
     26 main() {
     27 	tmux source-file ~/.tmux.conf >/dev/null 2>&1
     28 	case "${1}" in
     29 		start) timer ;;
     30 		stop) killtimer ; exit 0 ;;
     31 	esac
     32 }
     33 
     34 main "${1}"