A timer for tmux written in bash.
I wanted a timer to track work time, and I wanted it on my tmux bar. Other things I wanted was that the timer was kept hidden while it is counting, only showing the current count when it is stopped. I though this would be ideal for a timer to count work time.
This utility has 3 commands:
start
- starts a count if none is running, or ends a count if there is one runningpause
- pauses and resumes a countstart-from
- starts a count from a user-inputted time (e.g. start counting from 02:20:00)
The tmux bar will show the contents of a file with the current count.
-
Clone this repo or save
tmux_tempus.sh
somewhere (e.g. your tmux config directory) -
Add the following lines to your tmux config, replacing
<start key>
,<pause key>
and<start-from key>
, as well as<tmux_tempus.sh path>
bind <start key> run-shell 'bash <tmux_tempus.sh path> start > /dev/null'\; refresh-client -S
bind <pause key> run-shell 'bash <tmux_tempus.sh path> pause > /dev/null'\; refresh-client -S
bind-key <start-from key> command-prompt -p "Start Timer from:" 'run-shell "bash <tmux_tempus.sh path> start '%1' > /dev/null"'\; refresh-client -S
I like to use
S
,g
andP
as start, pause and start-from keys. That way I can use<prefix>+S
to start and stop a count,<prefix>+g
to pause and resume, and<prefix>+P>
to start a count from a spedific time. -
Add the timer file to the status bar. The best way is to add the variable
wg_timer
to your tmux config and putting it in your status barwg_timer="#[reverse]#(tail /tmp/tmux_tempus_bar)#[noreverse]"
An example status bar config, including only tmux-tempus, date and time:
set -g status-right "$wg_timer %Y-%m-%d %H:%M#"