mirror of
https://github.com/o0th/tmux-nova.git
synced 2026-09-10 07:16:28 -04:00
Resolve #7, upsert options
This commit is contained in:
parent
5297b4edd9
commit
f5fcae920c
|
|
@ -67,6 +67,13 @@ set -g @nova-double true
|
|||
set -g @nova-nerdfonts false
|
||||
```
|
||||
|
||||
### Pane
|
||||
|
||||
```bash
|
||||
# default: "#S:#I:#W"
|
||||
set -g @nova-pane "#{pane_title}"
|
||||
```
|
||||
|
||||
### Plugins
|
||||
|
||||
```bash
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ else
|
|||
cpu_thermometer=""
|
||||
fi
|
||||
|
||||
nerdfonts=$(option "@nova-nerdfonts" false)
|
||||
nerdfonts=$(get_option "@nova-nerdfonts" false)
|
||||
|
||||
if [ "$nerdfonts" = true ]; then
|
||||
echo "$($scripts/cpu_percentage.sh) $($scripts/ram_percentage.sh) $cpu_temp 糖$cpu_thermometer"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ else
|
|||
gpu_thermometer=""
|
||||
fi
|
||||
|
||||
nerdfonts=$(option "@nova-nerdfonts" false)
|
||||
nerdfonts=$(get_option "@nova-nerdfonts" false)
|
||||
|
||||
if [ "$nerdfonts" = true ]; then
|
||||
echo "$($scripts/gpu_percentage.sh) ﴿ $($scripts/gram_percentage.sh) $gpu_temp糖$gpu_thermometer"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ export LC_ALL=en_US.UTF-8
|
|||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
labels=$(option "@nova-plugins-mode-labels" "ω Ω")
|
||||
labels=$(get_option "@nova-plugins-mode-labels" "ω Ω")
|
||||
IFS=' ' read -r -a labels <<< $labels
|
||||
|
||||
echo "#{?client_prefix,${labels[1]},${labels[0]}}"
|
||||
|
|
|
|||
101
scripts/nova.sh
101
scripts/nova.sh
|
|
@ -8,11 +8,12 @@ source $current_dir/utils.sh
|
|||
# global options
|
||||
#
|
||||
|
||||
padding=$(option "@nova-padding" 1)
|
||||
nerdfonts=$(option "@nova-nerdfonts" false)
|
||||
nerdfonts_right=$(option "@nova-nerdfonts-right" )
|
||||
nerdfonts_left=$(option "@nova-nerdfonts-left" )
|
||||
double=$(option "@nova-double" true)
|
||||
padding=$(get_option "@nova-padding" 1)
|
||||
nerdfonts=$(get_option "@nova-nerdfonts" false)
|
||||
nerdfonts_right=$(get_option "@nova-nerdfonts-right" )
|
||||
nerdfonts_left=$(get_option "@nova-nerdfonts-left" )
|
||||
double=$(get_option "@nova-double" true)
|
||||
pane=$(get_option "@nova-pane" "#S:#I:#W")
|
||||
|
||||
#
|
||||
# double
|
||||
|
|
@ -26,61 +27,61 @@ fi
|
|||
# themes
|
||||
#
|
||||
|
||||
theme=$(option "@nova-theme" "nord")
|
||||
theme=$(get_option "@nova-theme" "dracula")
|
||||
|
||||
if [ $theme = "dracula" ]; then
|
||||
tmux set-option -g "@nova-pane-active-border-style" "#44475a"
|
||||
tmux set-option -g "@nova-pane-border-style" "#282a36"
|
||||
tmux set-option -g "@nova-plugins-mode-colors" "#8be9fd #282a36"
|
||||
tmux set-option -g "@nova-plugins-whoami-colors" "#bd93f9 #282a36"
|
||||
tmux set-option -g "@nova-status-style-bg" "#44475a"
|
||||
tmux set-option -g "@nova-status-style-fg" "#f8f8f2"
|
||||
tmux set-option -g "@nova-status-style-active-bg" "#6272a4"
|
||||
tmux set-option -g "@nova-status-style-active-fg" "#f8f8f2"
|
||||
tmux set-option -g "@nova-status-style-double-bg" "#282a36"
|
||||
tmux set-option -g "@nova-plugins-spotify-colors" "#282a36 #f8f8f2"
|
||||
tmux set-option -g "@nova-plugins-cpu-colors" "#282a36 #f8f8f2"
|
||||
tmux set-option -g "@nova-plugins-gpu-colors" "#282a36 #f8f8f2"
|
||||
upsert_option "@nova-pane-active-border-style" "#44475a"
|
||||
upsert_option "@nova-pane-border-style" "#282a36"
|
||||
upsert_option "@nova-plugins-mode-colors" "#8be9fd #282a36"
|
||||
upsert_option "@nova-plugins-whoami-colors" "#bd93f9 #282a36"
|
||||
upsert_option "@nova-status-style-bg" "#44475a"
|
||||
upsert_option "@nova-status-style-fg" "#f8f8f2"
|
||||
upsert_option "@nova-status-style-active-bg" "#6272a4"
|
||||
upsert_option "@nova-status-style-active-fg" "#f8f8f2"
|
||||
upsert_option "@nova-status-style-double-bg" "#282a36"
|
||||
upsert_option "@nova-plugins-spotify-colors" "#282a36 #f8f8f2"
|
||||
upsert_option "@nova-plugins-cpu-colors" "#282a36 #f8f8f2"
|
||||
upsert_option "@nova-plugins-gpu-colors" "#282a36 #f8f8f2"
|
||||
fi
|
||||
|
||||
if [ $theme = "nord" ]; then
|
||||
tmux set-option -g "@nova-pane-active-border-style" "#44475a"
|
||||
tmux set-option -g "@nova-pane-border-style" "#282a36"
|
||||
tmux set-option -g "@nova-plugins-mode-colors" "#88c0d0 #2e3440"
|
||||
tmux set-option -g "@nova-plugins-whoami-colors" "#81a1c1 #2e3440"
|
||||
tmux set-option -g "@nova-status-style-bg" "#4c566a"
|
||||
tmux set-option -g "@nova-status-style-fg" "#d8dee9"
|
||||
tmux set-option -g "@nova-status-style-active-bg" "#5e81ac"
|
||||
tmux set-option -g "@nova-status-style-active-fg" "#d8dee9"
|
||||
tmux set-option -g "@nova-status-style-double-bg" "#2e3440"
|
||||
tmux set-option -g "@nova-plugins-spotify-colors" "#2e3440 #d8dee9"
|
||||
tmux set-option -g "@nova-plugins-cpu-colors" "#2e3440 #d8dee9"
|
||||
tmux set-option -g "@nova-plugins-gpu-colors" "#2e3440 #d8dee9"
|
||||
upsert_option "@nova-pane-active-border-style" "#44475a"
|
||||
upsert_option "@nova-pane-border-style" "#282a36"
|
||||
upsert_option "@nova-plugins-mode-colors" "#88c0d0 #2e3440"
|
||||
upsert_option "@nova-plugins-whoami-colors" "#81a1c1 #2e3440"
|
||||
upsert_option "@nova-status-style-bg" "#4c566a"
|
||||
upsert_option "@nova-status-style-fg" "#d8dee9"
|
||||
upsert_option "@nova-status-style-active-bg" "#5e81ac"
|
||||
upsert_option "@nova-status-style-active-fg" "#d8dee9"
|
||||
upsert_option "@nova-status-style-double-bg" "#2e3440"
|
||||
upsert_option "@nova-plugins-spotify-colors" "#2e3440 #d8dee9"
|
||||
upsert_option "@nova-plugins-cpu-colors" "#2e3440 #d8dee9"
|
||||
upsert_option "@nova-plugins-gpu-colors" "#2e3440 #d8dee9"
|
||||
fi
|
||||
|
||||
#
|
||||
# status-interval
|
||||
#
|
||||
|
||||
status_interval=$(option "@nova-status-interval" 5)
|
||||
status_interval=$(get_option "@nova-status-interval" 5)
|
||||
tmux set-option -g status-interval $status_interval
|
||||
|
||||
#
|
||||
# status-style
|
||||
#
|
||||
|
||||
status_style_bg=$(option "@nova-status-style-bg")
|
||||
status_style_fg=$(option "@nova-status-style-fg")
|
||||
status_style_active_bg=$(option "@nova-status-style-active-bg")
|
||||
status_style_active_fg=$(option "@nova-status-style-active-fg")
|
||||
status_style_bg=$(get_option "@nova-status-style-bg")
|
||||
status_style_fg=$(get_option "@nova-status-style-fg")
|
||||
status_style_active_bg=$(get_option "@nova-status-style-active-bg")
|
||||
status_style_active_fg=$(get_option "@nova-status-style-active-fg")
|
||||
tmux set-option -g status-style "bg=$status_style_bg,fg=$status_style_fg"
|
||||
|
||||
#
|
||||
# pane
|
||||
#
|
||||
|
||||
pane_border_style=$(option "@nova-pane-border-style")
|
||||
pane_active_border_style=$(option "@nova-pane-active-border-style")
|
||||
pane_border_style=$(get_option "@nova-pane-border-style")
|
||||
pane_active_border_style=$(get_option "@nova-pane-active-border-style")
|
||||
tmux set-option -g pane-border-style "fg=${pane_border_style}"
|
||||
tmux set-option -g pane-active-border-style "fg=${pane_active_border_style}"
|
||||
|
||||
|
|
@ -88,7 +89,7 @@ tmux set-option -g pane-active-border-style "fg=${pane_active_border_style}"
|
|||
# status-left
|
||||
#
|
||||
|
||||
status_left_plugins=$(option "@nova-status-left-plugins" "mode whoami")
|
||||
status_left_plugins=$(get_option "@nova-status-left-plugins" "mode whoami")
|
||||
IFS=' ' read -r -a status_left_plugins <<< $status_left_plugins
|
||||
|
||||
tmux set-option -g status-left-length 100
|
||||
|
|
@ -97,7 +98,7 @@ tmux set-option -g status-left ""
|
|||
for plugin in "${status_left_plugins[@]}"; do
|
||||
if [ -f "$current_dir/$plugin.sh" ]; then
|
||||
|
||||
plugin_colors=$(option "@nova-plugins-$plugin-colors")
|
||||
plugin_colors=$(get_option "@nova-plugins-$plugin-colors")
|
||||
IFS=' ' read -r -a plugin_colors <<< $plugin_colors
|
||||
|
||||
if [ $nerdfonts = true ] && [ -n "$(tmux show-option -gqv status-left)" ]; then
|
||||
|
|
@ -119,12 +120,11 @@ if [ $nerdfonts = true ] && [ ! -z $nerdfonts_color ]; then
|
|||
tmux set-option -ga status-left "$nerdfonts_left"
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# status
|
||||
#
|
||||
|
||||
status_justify=$(option "@nova-status-justify" "left")
|
||||
status_justify=$(get_option "@nova-status-justify" "left")
|
||||
tmux set-option status-justify ${status_justify}
|
||||
|
||||
#
|
||||
|
|
@ -138,7 +138,7 @@ fi
|
|||
|
||||
tmux set-window-option -g window-status-format "#[fg=$status_style_fg]#[bg=$status_style_bg]"
|
||||
tmux set-window-option -ga window-status-format "$(padding $padding)"
|
||||
tmux set-window-option -ga window-status-format "#S:#I:#W"
|
||||
tmux set-window-option -ga window-status-format "$pane"
|
||||
tmux set-window-option -ga window-status-format "$(padding $padding)"
|
||||
|
||||
if [ $nerdfonts = true ]; then
|
||||
|
|
@ -148,7 +148,7 @@ else
|
|||
fi
|
||||
|
||||
tmux set-window-option -ga window-status-current-format "$(padding $padding)"
|
||||
tmux set-window-option -ga window-status-current-format "#S:#I:#W"
|
||||
tmux set-window-option -ga window-status-current-format "$pane"
|
||||
tmux set-window-option -ga window-status-current-format "$(padding $padding)"
|
||||
|
||||
if [ $nerdfonts = true ]; then
|
||||
|
|
@ -156,12 +156,11 @@ if [ $nerdfonts = true ]; then
|
|||
tmux set-window-option -ga window-status-current-format "$nerdfonts_left"
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# status-right
|
||||
#
|
||||
|
||||
status_right_plugins=$(option "@nova-status-right-plugins" "")
|
||||
status_right_plugins=$(get_option "@nova-status-right-plugins" "")
|
||||
IFS=' ' read -r -a status_right_plugins <<< $status_right_plugins
|
||||
|
||||
tmux set-option -g status-right-length 100
|
||||
|
|
@ -171,7 +170,7 @@ tmux set-option -g status-right ""
|
|||
for plugin in "${status_right_plugins[@]}"; do
|
||||
if [ -f "$current_dir/$plugin.sh" ]; then
|
||||
|
||||
plugin_colors=$(option "@nova-plugins-$plugin-colors")
|
||||
plugin_colors=$(get_option "@nova-plugins-$plugin-colors")
|
||||
IFS=' ' read -r -a plugin_colors <<< $plugin_colors
|
||||
|
||||
if [ $nerdfonts = true ] && [ ! -n "$(tmux show-option -gqv status-right)" ]; then
|
||||
|
|
@ -195,8 +194,8 @@ done
|
|||
# status-bottom-left
|
||||
#
|
||||
|
||||
status_style_double_bg=$(option "@nova-status-style-double-bg")
|
||||
status_bottom_left_plugins=$(option "@nova-status-bottom-left-plugins" "spotify")
|
||||
status_style_double_bg=$(get_option "@nova-status-style-double-bg")
|
||||
status_bottom_left_plugins=$(get_option "@nova-status-bottom-left-plugins" "spotify")
|
||||
IFS=' ' read -r -a status_bottom_left_plugins <<< $status_bottom_left_plugins
|
||||
|
||||
tmux set-option -g status-format[1] "#[fill=$status_style_double_bg]#[align=left]"
|
||||
|
|
@ -205,7 +204,7 @@ nerdfonts_color="$status_style_double_bg"
|
|||
for plugin in "${status_bottom_left_plugins[@]}"; do
|
||||
if [ -f "$current_dir/$plugin.sh" ]; then
|
||||
|
||||
plugin_colors=$(option "@nova-plugins-$plugin-colors")
|
||||
plugin_colors=$(get_option "@nova-plugins-$plugin-colors")
|
||||
IFS=' ' read -r -a plugin_colors <<< $plugin_colors
|
||||
|
||||
if [ $nerdfonts = true ] && [ "$(tmux show-option -gqv status-format[1])" != "#[align=left]"]; then
|
||||
|
|
@ -234,7 +233,7 @@ fi
|
|||
|
||||
nerdfonts_color="$status_style_double_bg"
|
||||
|
||||
status_bottom_right_plugins=$(option "@nova-status-bottom-plugins" "cpu gpu")
|
||||
status_bottom_right_plugins=$(get_option "@nova-status-bottom-plugins" "cpu gpu")
|
||||
IFS=' ' read -r -a status_bottom_right_plugins <<< $status_bottom_right_plugins
|
||||
|
||||
tmux set-option -ga status-format[1] "#[align=right]"
|
||||
|
|
@ -242,7 +241,7 @@ tmux set-option -ga status-format[1] "#[align=right]"
|
|||
for plugin in "${status_bottom_right_plugins[@]}"; do
|
||||
if [ -f "$current_dir/$plugin.sh" ]; then
|
||||
|
||||
plugin_colors=$(option "@nova-plugins-$plugin-colors")
|
||||
plugin_colors=$(get_option "@nova-plugins-$plugin-colors")
|
||||
IFS=' ' read -r -a plugin_colors <<< $plugin_colors
|
||||
|
||||
if [ $nerdfonts = true ]; then
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ export LC_ALL=en_US.UTF-8
|
|||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
nerdfonts=$(option "@nova-nerdfonts" false)
|
||||
nerdfonts=$(get_option "@nova-nerdfonts" false)
|
||||
|
||||
if [ "$nerdfonts" = true ]; then
|
||||
echo "$(spotifycli --playbackstatus) $(spotifycli --status)"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,20 @@
|
|||
#!/usr/bin/env bash
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
option() {
|
||||
get_option() {
|
||||
local option=$(tmux show-option -gqv "$1")
|
||||
[ -z $option ] && echo $2 || echo $option
|
||||
}
|
||||
|
||||
set_option() {
|
||||
tmux set-option -g "$1" "$2"
|
||||
}
|
||||
|
||||
upsert_option() {
|
||||
local option=$(get_option "$1" "$2")
|
||||
tmux set-option -g "$1" "$option"
|
||||
}
|
||||
|
||||
padding() {
|
||||
printf '%*s' $1
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue