Add last save timestamp in status

Introduces `continuum-timestamp` and `continuum-timestamp-format`
options.
pull/123/head
Sankhesh Jhaveri 2023-03-10 16:58:02 -05:00
parent 3e4bc35da4
commit 8c6a28562e
No known key found for this signature in database
GPG Key ID: 0430815DC0D85650
3 changed files with 25 additions and 0 deletions

View File

@ -15,3 +15,20 @@ When running, `#{continuum_status}` will show continuum save interval:
or if continuous saving is disabled:
Continuum status: off
### Last saved timestamp
Along with the current status, continuum can also display the last session save
timestamp to indicate when the last automatic session save happened. This can be
enabled by setting the tmux option `set -g @continuum-timestamp 'on'` in your
`tmux.conf`. The format of the timestamp follows UNIX `date` format and can be
set using `continuum-timestamp-option`.
Example usage:
set -g @continuum-timestamp 'on' # Enable last save timestamp in status
set -g @continuum-timestamp-format '%I:%M %p' # Show date as "HH:MM AM"
When running, `#{continuum_status}` will show continuum last-save timestamp:
Continuum status: 15 <11:54 AM>

View File

@ -12,6 +12,12 @@ print_status() {
if [ $save_int -gt 0 ]; then
style_wrap="$(get_tmux_option "$status_on_style_wrap_option" "")"
status="$save_int"
local tstamp_option="$(get_tmux_option "$status_timestamp_option")"
local tstamp_format="$(get_tmux_option "$status_timestamp_format_option" "%I:%M %p")"
if [ $tstamp_option == "on" ]; then
local tstamp="$(date +"$tstamp_format" -d @$(get_tmux_option "$last_auto_save_option"))"
status="$status <$tstamp>"
fi
else
style_wrap="$(get_tmux_option "$status_off_style_wrap_option" "")"
status="off"

View File

@ -35,6 +35,8 @@ status_script="#($CURRENT_DIR/scripts/continuum_status.sh)"
status_on_style_wrap_option="@continuum-status-on-wrap-style" # example value: "#[fg=green]#{value}#[fg=white]"
status_off_style_wrap_option="@continuum-status-off-wrap-style" # example value: "#[fg=yellow,bold]#{value}#[fg=white,nobold]"
status_wrap_string="\#{value}"
status_timestamp_option="@continuum-timestamp"
status_timestamp_format_option="@continuum-timestamp-format" # example value: "%I:%M %p"
systemd_service_name="tmux.service"
systemd_unit_file_path="$HOME/.config/systemd/user/${systemd_service_name}"