├── README.md
├── screenshots
├── split-statusbar-hide-off.png
├── split-statusbar-hide-on.png
├── split-statusbar-mode-off.png
└── split-statusbar-mode-on.png
├── scripts
└── helpers.sh
└── tmux-split-statusbar.tmux
/README.md:
--------------------------------------------------------------------------------
1 | # Tmux Plugin -split status bar
2 |
3 | This is an plugin that split stats bar into 2 parts (lines)
4 |
5 | `window part` - First line
6 |
7 | `status-left / status-right` part - Second line
8 |
9 | This plugin provides function to hide status-left / status-right as well, if you want to focus, pure silence environment.
10 |
11 | This plugin is compatible with Tmux plugin manager([TPM](https://github.com/tmux-plugins/tpm))
12 |
13 | This pllugin should work with any themes well.
14 |
15 | # Installation
16 | ## Installation with [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm) (recommended)
17 | ### Notice:
18 |
19 | Due to using the command set -g**a** status-left / status-right
20 |
21 | `And it would be better put "tmux-split-statusbar" config lines **AFTER** `status style like` setup !`
22 |
23 |
24 | ### Requirements:
25 | Requirements 1 : Make sure set these config lines **AFTER** `theme plugin`
26 |
27 | (keep this plugin at the very bottom of tmux.conf)
28 |
29 | Better **JUST** before this line
30 |
31 | ```bash
32 | run -b '~/.tmux/plugins/tpm/tpm'
33 | ```
34 |
35 | Requirements 2 : `tmux` version 3.0 (or higher), `bash`.
36 |
37 | Add plugin to the list of TPM plugins in `.tmux.conf`:
38 |
39 | set -g @plugin 'charlietag/tmux-split-statusbar'
40 |
41 | Hit `prefix + I` to fetch the plugin and source it.
42 |
43 | Status bar should be splited now
44 |
45 | ## Manual Installation
46 |
47 | Clone the repo:
48 |
49 | $ git clone https://github.com/charlietag/tmux-split-statusbar.git ~/clone/path
50 |
51 | Add this line to the bottom of `.tmux.conf`:
52 |
53 | run-shell ~/clone/path/tmux-split-statusbar.tmux
54 |
55 | Reload TMUX environment:
56 |
57 | # type this in terminal
58 | $ tmux source-file ~/.tmux.conf
59 |
60 | Status bar should be splited now
61 |
62 |
63 | # Examples
64 |
65 | Status bar splited (on): double lines
66 | 
67 |
68 | Status bar splited (off): single line
69 | 
70 |
71 | Status bar hide (on)
72 | 
73 |
74 | Status bar hide (off)
75 | 
76 |
77 |
78 | # Customization
79 |
80 | Here are all available options with their default values:
81 |
82 | ```bash
83 | @split-statusbar-mode 'on' # [ on | off]
84 |
85 | @split-statusbar-swap-lines 'off' # [ on | off ]
86 | # Enable this option to swap rows,
87 | # may be useful for those who prefer a status bar on top:
88 | # set -g status-position top
89 |
90 | @split-statusbar-bindkey '-n F11' # [ M-s | -n F11 | ... ]
91 | # bindkey for toggle statusbar-mode
92 | # define yourself just like bind-key, default: M-s
93 |
94 | @split-status-hide-bindkey '-n F12' # [ M-d | -n F12 | ... ]
95 | # bindkey for status-left / status-right hiding
96 | # define yourself just like bind-key, default: M-d
97 | ```
98 |
99 | Don't forget to reload tmux environment (`$ tmux source-file ~/.tmux.conf`)
100 | after you do this.
101 |
102 |
103 | # Usage
104 |
105 | Sample config in ~/.tmux.conf
106 |
107 | ```bash
108 | set -g @plugin 'charlietag/tmux-split-statusbar'
109 | set -g @split-statusbar-mode 'on' # [ on | off]
110 |
111 | set -g @split-statusbar-swap-lines 'off' # [ on | off]
112 |
113 | set -g @split-statusbar-bindkey '-n F11' # [ M-s | -n F11 | ... ]
114 | # bindkey for toggle statusbar-mode
115 | # define yourself just like bind-key, default: M-s
116 |
117 | set -g @split-status-hide-bindkey '-n F12' # [ M-d | -n F12 | ... ]
118 | # bindkey for status-left / status-right hiding
119 | # define yourself just like bind-key, default: M-d
120 | ```
121 |
122 | # Also read
123 |
124 | - [.tmux.conf](https://github.com/charlietag/tmux_settings/blob/master/tmux.conf) - Tmux configuration sample by CharlieTag
125 |
126 | # Other goodies
127 |
128 | - [tmux-themes](https://github.com/charlietag/tmux-themes) - simple colorful theme made by CharlieTag
129 |
130 | # License
131 |
132 | [MIT license](https://opensource.org/licenses/MIT)
133 |
134 | # Change Log
135 |
136 | * 2020/07/01
137 | * https://github.com/charlietag/tmux-split-statusbar/compare/v0.0.0...v0.0.1
138 | * fully compatible with https://github.com/tmux-plugins/tmux-continuum (auto-save-session in hide status mode)
139 | * add reload function to **reinitialize status bar** (for working with tmux themes like [charlietag/tmux-themes](https://github.com/charlietag/tmux-themes))
140 | * Use the following command to **reset status bar to new themes**
141 |
142 | ```bash
143 | ~/.tmux/plugins/tmux-split-statusbar/tmux-split-statusbar.tmux reload
144 | ```
145 | * 2021/07/14
146 | * https://github.com/charlietag/tmux-split-statusbar/compare/v0.0.1...v0.0.2
147 | * Fix issue Unwanted characters in window status #1
148 | * https://github.com/charlietag/tmux-split-statusbar/issues/1
149 | * 2023/01/13
150 | * https://github.com/charlietag/tmux-split-statusbar/compare/v0.0.2...v0.0.3
151 | * xargs `-i` is deprecated, use `-I{}` instead
152 | * 2023/10/30
153 | * https://github.com/charlietag/tmux-split-statusbar/compare/v0.0.3...v0.1.0
154 | * Add split-statusbar-swap-lines by [@awerebea](https://github.com/awerebea)
155 |
--------------------------------------------------------------------------------
/screenshots/split-statusbar-hide-off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/charlietag/tmux-split-statusbar/33a367beee7f266a6293b04f30e92c4dc248b276/screenshots/split-statusbar-hide-off.png
--------------------------------------------------------------------------------
/screenshots/split-statusbar-hide-on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/charlietag/tmux-split-statusbar/33a367beee7f266a6293b04f30e92c4dc248b276/screenshots/split-statusbar-hide-on.png
--------------------------------------------------------------------------------
/screenshots/split-statusbar-mode-off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/charlietag/tmux-split-statusbar/33a367beee7f266a6293b04f30e92c4dc248b276/screenshots/split-statusbar-mode-off.png
--------------------------------------------------------------------------------
/screenshots/split-statusbar-mode-on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/charlietag/tmux-split-statusbar/33a367beee7f266a6293b04f30e92c4dc248b276/screenshots/split-statusbar-mode-on.png
--------------------------------------------------------------------------------
/scripts/helpers.sh:
--------------------------------------------------------------------------------
1 | # --------------------- bind key ---------------------
2 | split_bind_key() {
3 | # unbind all tmux-split-statusbar related
4 | tmux list-keys |grep tmux-split-statusbar | awk '{print $2" "$3" "$4}' | xargs -I{} bash -c "tmux unbind-key {}"
5 |
6 | # Define bind key for status bar togle
7 | local bind_key="$(tmux show-option -gqv "@split-statusbar-bindkey")"
8 | [[ -z "${bind_key}" ]] && bind_key="M-s"
9 | tmux bind-key ${bind_key} run-shell '~/.tmux/plugins/tmux-split-statusbar/tmux-split-statusbar.tmux toggle'
10 |
11 | # Define bind key for status left right toggle
12 | local bind_key_hide="$(tmux show-option -gqv "@split-status-hide-bindkey")"
13 | [[ -z "${bind_key_hide}" ]] && bind_key_hide="M-d"
14 | tmux bind-key ${bind_key_hide} run-shell '~/.tmux/plugins/tmux-split-statusbar/tmux-split-statusbar.tmux hide'
15 | }
16 |
17 | # --------------------- Initialize ---------------------
18 | # --- backup default setting ---
19 | # status-format[6] - status_format_0_default
20 | # status-format[7] - status_format_1_default
21 | # @status-left-default - status_left_default
22 | # @status-right-default - status_right_default
23 | set_default_status_format() {
24 | local status_format_0_default="$(tmux show-option -gqv "status-format[6]")"
25 | #local status_format_1_default="$(tmux show-option -gqv "status-format[7]")"
26 |
27 | if [[ -z "${status_format_0_default}" ]]; then
28 | # --- status line ---
29 | local status_format_0_default="$(tmux show-option -gqv "status-format[0]")"
30 | local status_format_1_default="$(tmux show-option -gqv "status-format[1]")"
31 | tmux set -g status-format[6] "${status_format_0_default}"
32 | tmux set -g status-format[7] "${status_format_1_default}"
33 |
34 | # --- status left right ---
35 | local status_left_default="$(tmux show-option -gqv "status-left")"
36 | local status_right_default="$(tmux show-option -gqv "status-right")"
37 | tmux set -g @status-left-default "${status_left_default}"
38 | tmux set -g @status-right-default "${status_right_default}"
39 | fi
40 | }
41 |
42 | # --------------------- statusbar lines ---------------------
43 | split_statusbar_on() {
44 | local status_format_0_default="$(tmux show-option -gqv "status-format[6]")"
45 |
46 | # status_format_0_tobe="$(echo "${status_format_0_default}" | sed 's/:status-left//g' | sed 's/:status-right//g')"
47 | status_format_0_tobe="$(echo "${status_format_0_default}" | sed 's/#{T;=\/#{status-left-length}:status-left}//g' | sed 's/#{T;=\/#{status-right-length}:status-right}//g')"
48 | status_format_1_tobe="$(echo "${status_format_0_default}" | sed 's/:window-status-current-format//g' | sed 's/:window-status-format//g')"
49 | if [[ "${split_statusbar_swap_lines}" = "on" ]];then
50 | tmux set -g status-format[0] "${status_format_1_tobe}"
51 | tmux set -g status-format[1] "${status_format_0_tobe}"
52 | else
53 | tmux set -g status-format[0] "${status_format_0_tobe}"
54 | tmux set -g status-format[1] "${status_format_1_tobe}"
55 | fi
56 | tmux set -g status 2
57 | }
58 |
59 | split_statusbar_off() {
60 | local status_format_0_default="$(tmux show-option -gqv "status-format[6]")"
61 | local status_format_1_default="$(tmux show-option -gqv "status-format[7]")"
62 |
63 | tmux set -g status-format[0] "${status_format_0_default}"
64 | tmux set -g status-format[1] "${status_format_1_default}"
65 | tmux set -g status on
66 | }
67 |
68 | split_statusbar_toggle() {
69 | local status_format_current="$(tmux show-option -gqv "status-format[0]")"
70 | local status_format_0_default="$(tmux show-option -gqv "status-format[6]")"
71 | if [[ "${status_format_current}" = "${status_format_0_default}" ]]; then
72 | split_statusbar_on
73 | tmux set -g @split-statusbar-mode-setto "on"
74 | else
75 | split_statusbar_off
76 | tmux set -g @split-statusbar-mode-setto "off"
77 | fi
78 | }
79 |
80 | # --------------------- hide status left right ---------------------
81 | hide_status_on() {
82 | tmux set -g status-left "#[fg=colour232,bg=red,bold]#{?client_prefix, ,}#[fg=colour232,bg=colour203,bold]#{?pane_in_mode, ,}"
83 | tmux set -g status-right ""
84 |
85 | # For support tmux-coninuum
86 | local check_plugin_status="$(cat ~/.tmux.conf |awk '/^[ \t]*set(-option)? +-g +@plugin/ { gsub(/'\''/,""); gsub(/'\"'/,""); print $4 }' | grep 'tmux-plugins/tmux-continuum')"
87 |
88 | if [[ -n "${check_plugin_status}" ]]; then
89 | #if [[ -f ~/.tmux/plugins/tmux-continuum/continuum.tmux ]]; then
90 | # ~/.tmux/plugins/tmux-continuum/continuum.tmux >/dev/null 2>/dev/null
91 | #fi
92 | local plugin_script="$(readlink -m ~/.tmux/plugins/tmux-continuum/scripts/continuum_save.sh)"
93 | if [[ -f "${plugin_script}" ]]; then
94 | tmux set -g status-right "#(${plugin_script})"
95 | fi
96 |
97 | fi
98 |
99 | }
100 |
101 | hide_status_off() {
102 | local status_left_default="$(tmux show-option -gqv "@status-left-default")"
103 | local status_right_default="$(tmux show-option -gqv "@status-right-default")"
104 | tmux set -g status-left "${status_left_default}"
105 | tmux set -g status-right "${status_right_default}"
106 | }
107 |
108 | hide_status_toggle() {
109 | local status_left_current="$(tmux show-option -gqv "status-left")"
110 | local status_left_default="$(tmux show-option -gqv "@status-left-default")"
111 | if [[ "${status_left_current}" = "${status_left_default}" ]]; then
112 | hide_status_on
113 | tmux set -g @hide-statusbar-mode-setto "on"
114 | else
115 | hide_status_off
116 | tmux set -g @hide-statusbar-mode-setto "off"
117 | fi
118 | }
119 |
120 |
--------------------------------------------------------------------------------
/tmux-split-statusbar.tmux:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3 | source "$CURRENT_DIR/scripts/helpers.sh"
4 |
5 | main() {
6 | local split_statusbar_mode="$(tmux show-option -gqv "@split-statusbar-mode")"
7 | local split_statusbar_mode_setto="$(tmux show-option -gqv "@split-statusbar-mode-setto")"
8 | local hide_statusbar_mode_setto="$(tmux show-option -gqv "@hide-statusbar-mode-setto")"
9 | local split_statusbar_swap_lines="$(tmux show-option -gqv "@split-statusbar-swap-lines")"
10 | local toggle_flag="$1"
11 |
12 | if [[ "${toggle_flag}" = "reload" ]];then
13 | split_statusbar_off
14 | tmux set -g status-format[6] ""
15 | fi
16 |
17 | split_bind_key
18 | set_default_status_format
19 |
20 |
21 |
22 | if [[ "${toggle_flag}" = "toggle" ]];then
23 | split_statusbar_toggle
24 | elif [[ "${toggle_flag}" = "hide" ]];then
25 | hide_status_toggle
26 | else
27 |
28 | #---------------- split status bar ----------------------
29 | if [[ "${split_statusbar_mode_setto}" = "on" ]];then
30 | split_statusbar_on
31 | tmux set -g @split-statusbar-mode-setto "on"
32 | elif [[ "${split_statusbar_mode_setto}" = "off" ]];then
33 | split_statusbar_off
34 | tmux set -g @split-statusbar-mode-setto "off"
35 | else
36 | if [[ "${split_statusbar_mode}" = "on" ]];then
37 | split_statusbar_on
38 | tmux set -g @split-statusbar-mode-setto "on"
39 | else
40 | split_statusbar_off
41 | tmux set -g @split-statusbar-mode-setto "off"
42 | fi
43 | fi
44 |
45 | #---------------- Hide status bar ----------------------
46 | if [[ "${hide_statusbar_mode_setto}" = "on" ]];then
47 | hide_status_on
48 | tmux set -g @hide-statusbar-mode-setto "on"
49 | else
50 | hide_status_off
51 | tmux set -g @hide-statusbar-mode-setto "off"
52 | fi
53 |
54 | fi
55 |
56 | }
57 |
58 | main "$1"
59 |
--------------------------------------------------------------------------------