Skip to content

Commit 5c2ec14

Browse files
Merge pull request #360 from webdavis/synchronize-panes/feature/auto-hide
Synchronize Panes: new feature `auto-hide`
2 parents 9681c64 + 215af3e commit 5c2ec14

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

docs/CONFIG.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,15 +802,34 @@ nerdfont icons to consider:
802802

803803
### synchronize-panes - [up](#table-of-contents)
804804

805-
This widget displays whether the tmux panes are currently synchronised or not.
805+
This widget displays whether the tmux panes are currently synchronised.
806806

807807
To change the label:
808808

809809
```bash
810810
set -g @dracula-synchronize-panes-label "Sync"
811811
```
812812

813-
`set -g @dracula-refresh-rate 5` affects this widget
813+
The global refresh rate affects this widget:
814+
815+
```bash
816+
set -g @dracula-refresh-rate 5
817+
```
818+
819+
You can set a custom refresh rate just for synchronize-panes:
820+
821+
```bash
822+
set -g @dracula-synchronize-panes-refresh-rate "0.5" # default: unset
823+
```
824+
825+
**Note:** This only takes precedence for the synchronize-panes widget. This means it won't
826+
override the global `@dracula-refresh-rate`.
827+
828+
Alternatively, you can automatically hide the label when sync is `off`:
829+
830+
```bash
831+
set -g @dracula-synchronize-panes-auto-hide true # default: false
832+
```
814833

815834
### sys-temp - [up](#table-of-contents)
816835

scripts/synchronize_panes.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,25 @@ main()
1616
{
1717
# storing the refresh rate in the variable RATE, default is 5
1818
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
19-
synchronize_panes_label=$label
19+
20+
# Use the @dracula-synchronize-panes-refresh-rate plugin variable to override it.
21+
RATE_OVERRIDE=$(get_tmux_option "@dracula-synchronize-panes-refresh-rate" "")
22+
if [[ -n "$RATE_OVERRIDE" ]]; then
23+
RATE="$RATE_OVERRIDE"
24+
fi
25+
26+
synchronize_panes_auto_hide=$(get_tmux_option "@dracula-synchronize-panes-auto-hide" "false")
2027
synchronize_panes_status=$(get_synchronize_panes_status)
21-
echo "$synchronize_panes_label $synchronize_panes_status"
28+
synchronize_panes_label=$label
29+
30+
if [[ "$synchronize_panes_auto_hide" == 'true' ]]; then
31+
if [[ "$synchronize_panes_status" == 'on' ]]; then
32+
echo "$synchronize_panes_label"
33+
fi
34+
else
35+
echo "$synchronize_panes_label $synchronize_panes_status"
36+
fi
37+
2238
sleep $RATE
2339
}
2440

0 commit comments

Comments
 (0)