Added synchronize-panes plugin

This commit is contained in:
Janno Tjarks 2021-12-22 22:50:05 +01:00
parent cce69791b6
commit 09a96946ff
5 changed files with 53 additions and 1 deletions

View file

@ -48,7 +48,7 @@ To enable plugins set up the `@dracula-plugins` option in you `.tmux.conf` file,
The order that you define the plugins will be the order on the status bar left to right.
```bash
# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, weather, time
# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, weather, time, synchronize-panes
set -g @dracula-plugins "cpu-usage gpu-usage ram-usage"
```
@ -189,3 +189,11 @@ Switch from default fahrenheit to celsius
set -g @dracula-show-fahrenheit false
```
#### synchronize-panes options
Customize label
```bash
set -g @dracula-synchronize-panes-label "Sync"
```

View file

@ -29,6 +29,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul
* When prefix is enabled smiley face turns from green to yellow
* When charging, 'AC' is displayed
* If forecast information is available, a ☀, ☁, ☂, or ❄ unicode character corresponding with the forecast is displayed alongside the temperature
* Info if the Panes are synchronized
## Compatibility

View file

@ -23,6 +23,7 @@ main()
show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false)
show_day_month=$(get_tmux_option "@dracula-day-month" false)
show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5)
show_synchronize_panes_label=$(get_tmux_option "@dracula-synchronize-panes-label" "Sync")
IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather")
# Dracula Color Pallette
@ -185,6 +186,11 @@ main()
script="%a %m/%d %I:%M %p ${timezone} "
fi
fi
if [ $plugin = "synchronize-panes" ]; then
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-synchronize-panes-colors" "cyan dark_gray")
script="#($current_dir/synchronize_panes.sh $show_synchronize_panes_label)"
fi
if $show_powerline; then
tmux set-option -ga status-right "#[fg=${!colors[0]},bg=${powerbg},nobold,nounderscore,noitalics]${right_sep}#[fg=${!colors[1]},bg=${!colors[0]}] $script "

View file

@ -0,0 +1,26 @@
#!/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
label=$1
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $current_dir/utils.sh
get_synchronize_panes_status() {
current_synchronize_panes_status=$(get_tmux_window_option "synchronize-panes" "off")
echo $current_synchronize_panes_status
}
main()
{
# storing the refresh rate in the variable RATE, default is 5
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
synchronize_panes_label=$label
synchronize_panes_status=$(get_synchronize_panes_status)
echo "$synchronize_panes_label $synchronize_panes_status"
sleep $RATE
}
# run main driver
main

View file

@ -11,6 +11,17 @@ get_tmux_option() {
fi
}
get_tmux_window_option() {
local option=$1
local default_value=$2
local option_value=$(tmux show-window-options -v "$option")
if [ -z "$option_value" ]; then
echo $default_value
else
echo $option_value
fi
}
# normalize the percentage string to always have a length of 5
normalize_percent_len() {
# the max length that the percent can reach, which happens for a two digit number with a decimal house: "99.9%"