-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Customise status with time remaining #120
Comments
Could you please tell me how to incorporate that in my |
As I mentioned, it's not something you can currently achieve using just the Here are the changes I made to diff --git a/scripts/continuum_status.sh b/scripts/continuum_status.sh
index 280cf00..83b488b 100755
--- a/scripts/continuum_status.sh
+++ b/scripts/continuum_status.sh
@@ -4,21 +4,39 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/helpers.sh"
source "$CURRENT_DIR/variables.sh"
+source "$CURRENT_DIR/shared.sh"
+
+get_interval() {
+ get_tmux_option "$auto_save_interval_option" "$auto_save_interval_default"
+}
+
+
+current_timestamp() {
+ echo "$(date +%s)"
+ "$(date +%s)"
+}
print_status() {
- local save_int="$(get_tmux_option "$auto_save_interval_option")"
+ local save_int="$(get_tmux_option "$auto_save_interval_option")"
local status=""
+ local style_wrap="$(get_tmux_option "$status_on_style_wrap_option" "")"
local style_wrap
if [ $save_int -gt 0 ]; then
- style_wrap="$(get_tmux_option "$status_on_style_wrap_option" "")"
- status="$save_int"
+ local last_saved_timestamp="$(get_tmux_option "$last_auto_save_option" "0")"
+ local interval_minutes="$(get_interval)"
+ local interval_seconds="$((interval_minutes * 60))"
+ local next_run="$((last_saved_timestamp + $interval_seconds))"
+ local now="$(date +%s)"
+ local secs="$((next_run - now))"
+ local til_next_save=$(printf '%02dh:%02dm:%02ds\n' $((secs/3600)) $((secs%3600/60)) $((secs%60)))
+ status="$til_next_save"
else
- style_wrap="$(get_tmux_option "$status_off_style_wrap_option" "")"
- status="off"
+ style_wrap="$(get_tmux_option "$status_off_style_wrap_option" "")"
+ status="off"
fi
if [ -n "$style_wrap" ]; then
- status="${style_wrap/$status_wrap_string/$status}"
+ status="${style_wrap/$status_wrap_string/$status}"
fi
echo "$status"
}
Git diff attached as a txt file: or as a drop-in replacement: NB: This needs to be renamed to remove the trailing .txt - that was just so that github would accept it! |
The corresponding line in the set -g status-right '💾#{continuum_status}#[fg=colour233,bg=colour241,bold] %d/%m #[fg=colour233,bg=colour245,bold] %H:%M:%S ' |
Thank you for the explanation. |
I wanted to see a "time to next save" instead of just the time between saves, so for now I've just hacked away at https://github.com/tmux-plugins/tmux-continuum/blob/master/scripts/continuum_status.sh, so that I now see:
Do you have any plans to add functionality to make such customization easier / not require messing with the internals of this plugin (or is that already possible and I missed it)?
The text was updated successfully, but these errors were encountered: