Merge pull request #138 from JannoTjarks/synchronize-panes

Added plugin for the window option "Synchronize panes"
This commit is contained in:
Ethan Edwards 2023-07-12 14:22:32 -04:00 committed by GitHub
commit ef42ec68ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 53 additions and 3 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. The order that you define the plugins will be the order on the status bar left to right.
```bash ```bash
# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, tmux-ram-usage, network, network-bandwidth, network-ping, attached-clients, network-vpn, weather, time, spotify-tui, kubernetes-context # available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, tmux-ram-usage, network, network-bandwidth, network-ping, attached-clients, network-vpn, weather, time, spotify-tui, kubernetes-context, synchronize-panes
set -g @dracula-plugins "cpu-usage gpu-usage ram-usage" set -g @dracula-plugins "cpu-usage gpu-usage ram-usage"
``` ```
@ -298,6 +298,13 @@ Hide your location
set -g @dracula-show-location false set -g @dracula-show-location false
``` ```
#### synchronize-panes options
Customize label
```bash
set -g @dracula-synchronize-panes-label "Sync"
```
#### attached-clients options #### attached-clients options
Set the minimum number of clients to show (otherwise, show nothing) Set the minimum number of clients to show (otherwise, show nothing)
@ -311,5 +318,4 @@ Set the label when there is one client, or more than one client
```bash ```bash
set -g @dracula-clients-singular client set -g @dracula-clients-singular client
set -g @dracula-clients-plural clients set -g @dracula-clients-plural clients
``` ```

View file

@ -32,6 +32,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 prefix is enabled smiley face turns from green to yellow
- When charging, 'AC' is displayed - When charging, 'AC' is displayed
- If forecast information is available, a ☀, ☁, ☂, or ❄ unicode character corresponding with the forecast is displayed alongside the temperature - If forecast information is available, a ☀, ☁, ☂, or ❄ unicode character corresponding with the forecast is displayed alongside the temperature
- Info if the Panes are synchronized
- Spotify playback (needs the tool spotify-tui installed) - Spotify playback (needs the tool spotify-tui installed)
- Current kubernetes context - Current kubernetes context
- Current working directory of tmux pane - Current working directory of tmux pane

View file

@ -23,6 +23,7 @@ main()
show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false) show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false)
show_day_month=$(get_tmux_option "@dracula-day-month" false) show_day_month=$(get_tmux_option "@dracula-day-month" false)
show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5) show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5)
show_synchronize_panes_label=$(get_tmux_option "@dracula-synchronize-panes-label" "Sync")
time_format=$(get_tmux_option "@dracula-time-format" "") time_format=$(get_tmux_option "@dracula-time-format" "")
show_kubernetes_context_label=$(get_tmux_option "@dracula-kubernetes-context-label" "") show_kubernetes_context_label=$(get_tmux_option "@dracula-kubernetes-context-label" "")
IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather") IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather")
@ -234,6 +235,11 @@ main()
else else
continue continue
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 if $show_powerline; then
if $show_empty_plugins; then if $show_empty_plugins; then

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 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 the percentage string to always have a length of 5
normalize_percent_len() { normalize_percent_len() {
# the max length that the percent can reach, which happens for a two digit number with a decimal house: "99.9%" # the max length that the percent can reach, which happens for a two digit number with a decimal house: "99.9%"