diff --git a/config/src/config.rs b/config/src/config.rs index 1820c3f02..6cd4f6631 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -389,6 +389,12 @@ pub struct Config { #[dynamic(default = "default_true")] pub show_tab_index_in_tab_bar: bool, + #[dynamic(default = "default_true")] + pub show_tabs_in_tab_bar: bool, + + #[dynamic(default = "default_true")] + pub show_new_tab_button_in_tab_bar: bool, + /// If true, show_tab_index_in_tab_bar uses a zero-based index. /// The default is false and the tab shows a one-based index. #[dynamic(default)] diff --git a/docs/changelog.md b/docs/changelog.md index 549dc492f..b729fd228 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -46,6 +46,10 @@ As features stabilize some brief notes about them will accumulate here. * [ActivateKeyTable](config/lua/keyassignment/ActivateKeyTable.md) now also supports `prevent_fallback = true` as a parameter. [#2702](https://github.com/wez/wezterm/issues/2702) +* [show_tabs_in_tab_bar](config/lua/config/show_tabs_in_tab_bar.md) and + [show_new_tab_button_in_tab_bar](config/lua/config/show_new_tab_button_in_tab_bar.md) + config options to customize the tab bar appearance. + [#2082](https://github.com/wez/wezterm/issues/2082) #### Fixed * Wayland: key repeat gets stuck after pressing two keys in quick succession. diff --git a/docs/config/lua/config/show_new_tab_button_in_tab_bar.md b/docs/config/lua/config/show_new_tab_button_in_tab_bar.md new file mode 100644 index 000000000..c5937d19c --- /dev/null +++ b/docs/config/lua/config/show_new_tab_button_in_tab_bar.md @@ -0,0 +1,28 @@ +# `show_new_tab_button_in_tab_bar = true` + +*Since: nightly builds only* + +When set to `true` (the default), the tab bar will display the new-tab button, +which can be left-clicked to create a new tab, or right-clicked to display the +[Launcher Menu](../../launch.md). + +When set to `false`, the new-tab button will not be drawn into the tab bar. + +This example turns off the tabs and new-tab button, leaving just the left and +right status areas: + +```lua +local wezterm = require 'wezterm' + +wezterm.on('update-right-status', function(window, pane) + window:set_left_status 'left' + window:set_right_status 'right' +end) + +return { + use_fancy_tab_bar = false, + show_tabs_in_tab_bar = false, + show_new_tab_button_in_tab_bar = false, +} +``` + diff --git a/docs/config/lua/config/show_tabs_in_tab_bar.md b/docs/config/lua/config/show_tabs_in_tab_bar.md new file mode 100644 index 000000000..b887a2e7a --- /dev/null +++ b/docs/config/lua/config/show_tabs_in_tab_bar.md @@ -0,0 +1,26 @@ +# `show_tabs_in_tab_bar = true` + +*Since: nightly builds only* + +When set to `true` (the default), the tab bar will display the tabs associated +with the current window. + +When set to `false`, the tabs will not be drawn into the tab bar. + +This example turns off the tabs and new-tab button, leaving just the left and +right status areas: + +```lua +local wezterm = require 'wezterm' + +wezterm.on('update-right-status', function(window, pane) + window:set_left_status 'left' + window:set_right_status 'right' +end) + +return { + use_fancy_tab_bar = false, + show_tabs_in_tab_bar = false, + show_new_tab_button_in_tab_bar = false, +} +``` diff --git a/wezterm-gui/src/tabbar.rs b/wezterm-gui/src/tabbar.rs index d49f2a0ec..f7ce935c1 100644 --- a/wezterm-gui/src/tabbar.rs +++ b/wezterm-gui/src/tabbar.rs @@ -226,22 +226,26 @@ impl TabBarState { let mut active_tab_no = 0; - let tab_titles: Vec = tab_info - .iter() - .map(|tab| { - if tab.is_active { - active_tab_no = tab.tab_index; - } - compute_tab_title( - tab, - tab_info, - pane_info, - config, - false, - config.tab_max_width, - ) - }) - .collect(); + let tab_titles: Vec = if config.show_tabs_in_tab_bar { + tab_info + .iter() + .map(|tab| { + if tab.is_active { + active_tab_no = tab.tab_index; + } + compute_tab_title( + tab, + tab_info, + pane_info, + config, + false, + config.tab_max_width, + ) + }) + .collect() + } else { + vec![] + }; let titles_len: usize = tab_titles.iter().map(|s| s.len).sum(); let number_of_tabs = tab_titles.len(); @@ -334,7 +338,7 @@ impl TabBarState { } // New tab button - { + if config.show_new_tab_button_in_tab_bar { let hover = is_tab_hover(mouse_x, x, new_tab_hover.len()); let new_tab_button = if hover { &new_tab_hover } else { &new_tab };