Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .github/assets/tmux-nova-plugin-variables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 36 additions & 1 deletion .github/documentation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Documentation
## Documentation

### Pane

Expand Down Expand Up @@ -120,3 +120,38 @@ set -g @nova-segment-bright-colors "#282a36 #f8f8f2"
set -g @nova-segments-1-left "bleft"
set -g @nova-segments-1-right "bright"
```

### Use plugin variables

Define variables you want to load to be used in segments.

<p align="center">
<a><img src="assets/tmux-nova-plugin-variables.png" alt="screenshot"></a>
</p>

```bash
# Load plugin variables to be used in tmux-nova, separated by space
# before declaration of plugins
run-shell "~/.tmux/plugins/tmux-nova/scripts/load_plugin_variables.sh pomodoro_status music_percentage music_status artist track"

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-battery'
set -g @plugin 'robhurring/tmux-spotify'
set -g @plugin 'olimorris/tmux-pomodoro-plus'
set -g @plugin 'o0th/tmux-nova' # Must be the last on the list

set -g @nova-segment-pomodoro "#(#{pomodoro_status})"
set -g @nova-segment-pomodoro-colors "colour1 colour8"

set -g @nova-segment-battery "#(#{battery_percentage})"
set -g @nova-segment-battery-colors "colour11 colour8"

set -g @nova-segment-spotify "#(#{music_status}) #(#{artist}): #(#{track})"
set -g @nova-segment-spotify-colors "colour4 colour8"

set -g @nova-segment-time "%d/%m %H:%M"
set -g @nova-segment-time-colors "colour5 colour8"

set -g @nova-segments-0-right "pomodoro spotify battery time"
```
14 changes: 14 additions & 0 deletions scripts/load_plugin_variables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
export LC_ALL=en_US.UTF-8

tmux set-option -g status-left ""

tmux set-environment -g @nova-load-variables ""
all=""

for var in "$@"
do
tmux set-option -ga status-left "#{$var}*"
all+="$var "
done
tmux set-environment -g @nova-load-variables "$all"
20 changes: 20 additions & 0 deletions scripts/nova.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,26 @@ pane_active_border_style=$(get_option "@nova-pane-active-border-style" "#44475a"
tmux set-option -g pane-border-style "fg=${pane_border_style}"
tmux set-option -g pane-active-border-style "fg=${pane_active_border_style}"

#
# load variables
#

var_names=$(tmux show-environment -g @nova-load-variables | sed 's/@nova-load-variables=//')
IFS=' ' read -r -a var_names<<< $var_names
length=${#var_names[@]}

vars=$(get_option "status-left" "")
IFS='*' read -r -a vars<<< $vars

for ((j = 0; j < ${length}; j++)); do
interpolated_var="${vars[$j]}"
var_name="${var_names[$j]}"

stripped_var=$(echo $interpolated_var | sed 's/#(//' | sed 's/)//')
tmux set-environment -g "$var_name" "$stripped_var"
done


#
# segments-0-left
#
Expand Down