From 52ded28d65c6fbb5e3c0e441bf29ab7a23e06e1f Mon Sep 17 00:00:00 2001 From: MrSandman Date: Thu, 27 Jul 2023 18:39:04 +0200 Subject: [PATCH] feat!: separated window list behaviour (#14) --- readme.md | 11 +++++--- rose-pine.tmux | 71 ++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 59 insertions(+), 23 deletions(-) diff --git a/readme.md b/readme.md index 6cf4d64..b94accb 100644 --- a/readme.md +++ b/readme.md @@ -37,11 +37,15 @@ set -g @rose_pine_variant 'main' # Options are 'main', 'moon' or 'dawn' set -g @rose_pine_host 'on' # Enables hostname in the status bar set -g @rose_pine_date_time '' # It accepts the date UNIX command format (man date for info) set -g @rose_pine_user 'on' # Turn on the username component in the statusbar -set -g @rose_pine_window_tabs_enabled 'on' # When active, show program instead of current directory -set -g @rose_pine_bar_bg_disabls 'on' +set -g @rose_pine_bar_bg_disable 'on' # If set to 'on', disables background color, for transparent terminal emulators set -g @rose_pine_only_windows 'on' # Leaves only the window module, for max focus and space +set -g @rose_pine_default_window_behavior 'on' # Forces tmux default window list behaviour +set -g @rose_pine_show_current_program 'on' # Forces tmux to show the current running program as window name +set -g @rose_pine_show_pane_directory 'on' # Forces tmux to show the current directory as +# Previously set -g @rose_pine_window_tabs_enabled + # Example values for these can be: set -g @rose_pine_left_separator ' > ' # The strings to use as separators are 1-space padded set -g @rose_pine_right_separator ' < ' # Accepts both normal chars & nerdfont icons @@ -62,9 +66,10 @@ set -g @rose_pine_width_to_hide '80' # Specify a terminal width to toggle off mo set -g @rose_pine_window_count '5' # Specify a number of windows, if there are more than the number, do the same as width_to_hide ``` - The separator options should go back to the defaults ( →, ← and | NerdFont characters) if the options are unset and you close all tmux sessions (a full restart) -- Both the `@rose_pine_window_tabs_enabled` and `@rose_pine_bar_bg_disable` operate like the separators. - The `@rose_pine_width_to_hide` and `rose_pine_window_count` settings do not refresh automatically. They need to be refreshed manually, their current state is discussed [here](https://github.com/rose-pine/tmux/issues/10). +- For `@rose_pine_window_tabs_enabled` and any further naming changes / notices, see issue #14. +> This has been developed on tmux v3.2a on Pop_OS! (Ubuntu). If there are problems with other versions, do let me know ## Gallery diff --git a/rose-pine.tmux b/rose-pine.tmux index 7528b53..dc8b994 100755 --- a/rose-pine.tmux +++ b/rose-pine.tmux @@ -34,6 +34,12 @@ setw() { tmux_commands+=(set-window-option -gq "$option" "$value" ";") } +unset_option() { + local option=$1 + local value=$2 + tmux_commands+=(set-option -gu "$option" ";") +} + main() { local theme @@ -146,10 +152,18 @@ main() { local directory directory="$(get_tmux_option "@rose_pine_directory" "")" - # Changes between directory or current program for the window name - local wt_enabled - wt_enabled="$(get_tmux_option "@rose_pine_window_tabs_enabled" "off")" - readonly wt_enabled + # WARN: Breaking changes here: Documentation needs to be updated + local show_current_program + show_current_program="$(get_tmux_option "@rose_pine_show_current_program" "")" + readonly show_current_program + + local window_directory + window_directory="$(get_tmux_option "@rose_pine_show_pane_directory" "")" + readonly window_directory + + local default_window_behavior + default_window_behavior="$(get_tmux_option "@rose_pine_default_window_behavior" "")" + readonly default_window_behavior # Changes the background color for the current active window # TODO: Together with line 251-269, end development for this feature @@ -216,6 +230,7 @@ main() { left_separator="$(get_tmux_option "@rose_pine_left_separator" "  ")" local field_separator + # NOTE: Don't remove field_separator="$(get_tmux_option "@rose_pine_field_separator" " | " )" # END @@ -242,7 +257,7 @@ main() { readonly show_user="#[fg=$thm_iris]#(whoami)#[fg=$thm_subtle]$right_separator#[fg=$thm_subtle]$username_icon" local show_host - readonly show_host="$field_separator#[fg=$thm_text]#H#[fg=$thm_subtle]$right_separator#[fg=$thm_subtle]$hostname_icon" + readonly show_host="$spacer#[fg=$thm_text]#H#[fg=$thm_subtle]$right_separator#[fg=$thm_subtle]$hostname_icon" local show_date_time readonly show_date_time=" #[fg=$thm_foam]$date_time#[fg=$thm_subtle]$right_separator#[fg=$thm_subtle]$date_time_icon " @@ -251,10 +266,11 @@ main() { readonly show_directory="$spacer#[fg=$thm_subtle]$current_folder_icon #[fg=$thm_rose]#{b:pane_current_path} " local show_directory_in_window_status - readonly show_directory_in_window_status="#I$left_separator#[fg=$thm_gold,bg=""]#{b:pane_current_path}" + # BUG: It doesn't let the user pass through a custom window name + show_directory_in_window_status="#I$left_separator#[fg=$thm_gold,bg=""]#{b:pane_current_path}" local show_directory_in_window_status_current - readonly show_directory_in_window_status_current="#I$left_separator#[fg=$thm_gold,bg=""]#{b:pane_current_path}" + show_directory_in_window_status_current="#I$left_separator#[fg=$thm_gold,bg=""]#{b:pane_current_path}" # TODO: This needs some work and testing, rn I can't figure it out # if [[ "$active_window_color" == "love" ]]; then @@ -276,30 +292,42 @@ main() { # show_window_in_window_status_current="#[bg=$thm_iris,bg=$thm_base]#I$left_separator#W" # fi - # Left column placement: Determined by the set status-left on line 231 + # Left status column placement: Determined by the set status-left on line 344 - # Right columns organization: + # Right status and organization: - # Right column shows nothing by default + # Right status shows nothing by default local right_column - # Window status by default shows the current directory basename - local window_status_format=$show_directory_in_window_status - local window_status_current_format=$show_directory_in_window_status_current - # This if statement allows the bg colors to be null if the user decides so + # It sets the base colors for active / inactive, no matter the window appearence switcher choice + # TEST: This needs to be tested soon if [[ "$bar_bg_disable" == "on" ]]; then set status-style "fg=$thm_pine,bg=0" show_window_in_window_status="#[fg=$thm_iris,bg=0]#I#[fg=$thm_iris,bg=0]$left_separator#[fg=$thm_iris,bg=0]#W" show_window_in_window_status_current="#[fg=$thm_gold,bg=0]#I#[fg=$thm_gold,bg=0]$left_separator#[fg=$thm_gold,bg=0]#W" + show_directory_in_window_status="#[fg=$thm_iris,bg=0]#I#[fg=$thm_iris,bg=0]$left_separator#[fg=$thm_iris,bg=0]#{b:pane_current_path}" + show_directory_in_window_status_current="#[fg=$thm_gold,bg=0]#I#[fg=$thm_gold,bg=0]$left_separator#[fg=$thm_gold,bg=0]#{b:pane_current_path}" + set window-status-style "fg=$thm_iris,bg=0" + set window-status-current-style "fg=$thm_gold,bg=0" fi - # This option toggles between the default (current directory for the window's pane) - # and the $wt_enabled option, which is the tmux default behaviour - # Will make it 2 options instead of 1 :) - if [[ "$wt_enabled" == "on" ]]; then + # Window appearence switcher: 3 options for the user + if [[ "$show_current_program" == "on" ]]; then window_status_format=$show_window_in_window_status window_status_current_format=$show_window_in_window_status_current + setw window-status-format "$window_status_format" + setw window-status-current-format "$window_status_current_format" + # See line 268 + elif [[ "$window_directory" ]]; then + local window_status_format=$show_directory_in_window_status + local window_status_current_format=$show_directory_in_window_status_current + setw window-status-format "$window_status_format" + setw window-status-current-format "$window_status_current_format" + # Base behaviour, but whit cool colors + elif [[ "$default_window_behavior" == "on" || "$default_window_behavior" == "" ]]; then + unset_option window-status-format + unset_option window-status-current-format fi if [[ "$user" == "on" ]]; then @@ -328,6 +356,7 @@ main() { local current_window_width current_window_width=$(tmux display -p "#{window_width}") + # NOTE: Can possibly integrate the $only_windows mode into this if [[ "$prioritize_windows" == "on" ]]; then if [[ "$current_window_count" -gt "$user_window_count" || "$current_window_width" -lt "$user_window_width" ]]; then set status-left "$show_session$show_window$show_directory" @@ -338,6 +367,7 @@ main() { set status-right "$right_column" fi + # Defaults to a NerdFont icon, user can change through an option if [[ "$window_status_separator" != "  " ]]; then setw window-status-separator "$window_status_separator" else @@ -350,8 +380,9 @@ main() { set status-right "" fi - setw window-status-format "$window_status_format" - setw window-status-current-format "$window_status_current_format" + # NOTE: Dont remove this, it can be useful for references + # setw window-status-format "$window_status_format" + # setw window-status-current-format "$window_status_current_format" # tmux integrated modes