Add plugin for tmux-continuum status
This commit is contained in:
parent
b603b24bd6
commit
5af1faa367
3 changed files with 101 additions and 1 deletions
21
INSTALL.md
21
INSTALL.md
|
@ -319,3 +319,24 @@ Set the label when there is one client, or more than one client
|
|||
set -g @dracula-clients-singular client
|
||||
set -g @dracula-clients-plural clients
|
||||
```
|
||||
|
||||
#### continuum options
|
||||
|
||||
Hide output if no save has been performed recently
|
||||
(otherwise, show the continuum save interval)
|
||||
|
||||
```bash
|
||||
set -g @dracula-continuum-mode alert
|
||||
```
|
||||
|
||||
Show the time since the last continuum save
|
||||
|
||||
```bash
|
||||
set -g @dracula-continuum-mode time
|
||||
```
|
||||
|
||||
In alert mode, show if a the last save was performed less then one minute ago (default is 15 seconds)
|
||||
|
||||
```bash
|
||||
set -g @dracula-continuum-time-threshold 60
|
||||
```
|
||||
|
|
75
scripts/continuum.sh
Executable file
75
scripts/continuum.sh
Executable file
|
@ -0,0 +1,75 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
# configuration
|
||||
# @dracula-continuum-mode default (default|alert|time)
|
||||
# @dracula-continuum-time-threshold 15
|
||||
|
||||
alert_mode="@dracula-continuum-mode"
|
||||
time_threshold="@dracula-continuum-time-threshold"
|
||||
warn_threshold=15
|
||||
|
||||
last_auto_save_option="@continuum-save-last-timestamp"
|
||||
auto_save_interval_option="@continuum-save-interval"
|
||||
auto_save_interval_default="15"
|
||||
|
||||
current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
current_timestamp() {
|
||||
echo "$(date +%s)"
|
||||
}
|
||||
|
||||
time_since_last_run_passed() {
|
||||
local last_saved_timestamp="$(get_tmux_option "$last_auto_save_option" "0")"
|
||||
printf "%s" "$(($(current_timestamp) - last_saved_timestamp))"
|
||||
}
|
||||
|
||||
print_status() {
|
||||
local mode="$(get_tmux_option "$alert_mode" "default")"
|
||||
local threshold="$(get_tmux_option "$time_threshold" "15")"
|
||||
local save_int="$(get_tmux_option "$auto_save_interval_option" "$auto_save_interval_default")"
|
||||
local interval_seconds="$((save_int * 60))"
|
||||
local status=""
|
||||
local time_delta="$(time_since_last_run_passed)"
|
||||
local time_delta_minutes="$((time_delta / 60))"
|
||||
|
||||
case "$mode" in
|
||||
time)
|
||||
if [[ $save_int -gt 0 ]]; then
|
||||
if [[ "$time_delta" -gt $((interval_seconds+warn_threshold)) ]]; then
|
||||
status="no save after $time_delta_minutes minutes!"
|
||||
else
|
||||
status="$time_delta_minutes"
|
||||
fi
|
||||
else
|
||||
status="off"
|
||||
fi
|
||||
;;
|
||||
|
||||
alert)
|
||||
if [[ "$time_delta" -gt $((interval_seconds+warn_threshold)) ]]; then
|
||||
status="no save after $time_delta_minutes minutes!"
|
||||
elif [[ "$time_delta" -le "$threshold" ]]; then
|
||||
status="saved"
|
||||
elif [[ $save_int -gt 0 ]]; then
|
||||
status=""
|
||||
else
|
||||
status="off"
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
if [[ "$time_delta" -le "$threshold" ]]; then
|
||||
status="saved"
|
||||
elif [[ $save_int -gt 0 ]]; then
|
||||
status="$save_int"
|
||||
else
|
||||
status="off"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
echo "$status"
|
||||
}
|
||||
print_status
|
|
@ -212,6 +212,10 @@ main()
|
|||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-terraform-colors" "light_purple dark_gray")
|
||||
script="#($current_dir/terraform.sh $terraform_label)"
|
||||
|
||||
elif [ $plugin = "continuum" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-continuum-colors" "cyan dark_gray")
|
||||
script="#($current_dir/continuum.sh)"
|
||||
|
||||
elif [ $plugin = "weather" ]; then
|
||||
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-weather-colors" "orange dark_gray")
|
||||
script="#($current_dir/weather_wrapper.sh $show_fahrenheit $show_location $fixed_location)"
|
||||
|
|
Loading…
Reference in a new issue