diff options
author | Lovecraftian Horror <LovecraftianHorror@pm.me> | 2021-07-08 14:16:25 -0400 |
---|---|---|
committer | Lovecraftian Horror <LovecraftianHorror@pm.me> | 2021-07-08 14:16:25 -0400 |
commit | 4fcf558156dec6cfebd9fc6ba8605594369fded6 (patch) | |
tree | f783ff1424bd645c643377401041f105f86953aa /default-plugins/tab-bar | |
parent | 50d049a0edd2b342b4c6e9e279d0be77c2c5398d (diff) |
Display session name within session
Diffstat (limited to 'default-plugins/tab-bar')
-rw-r--r-- | default-plugins/tab-bar/src/line.rs | 11 | ||||
-rw-r--r-- | default-plugins/tab-bar/src/main.rs | 1 |
2 files changed, 9 insertions, 3 deletions
diff --git a/default-plugins/tab-bar/src/line.rs b/default-plugins/tab-bar/src/line.rs index cad5b7207..3ebeaac31 100644 --- a/default-plugins/tab-bar/src/line.rs +++ b/default-plugins/tab-bar/src/line.rs @@ -144,8 +144,12 @@ fn add_next_tabs_msg( title_bar.push(right_more_message); } -fn tab_line_prefix(palette: Palette) -> LinePart { - let prefix_text = " Zellij ".to_string(); +fn tab_line_prefix(session_name: Option<&str>, palette: Palette) -> LinePart { + let mut prefix_text = " Zellij ".to_string(); + if let Some(name) = session_name { + prefix_text.push_str(&format!("({}) ", name)); + } + let prefix_text_len = prefix_text.chars().count(); let prefix_styled_text = style!(palette.white, palette.cyan) .bold() @@ -165,6 +169,7 @@ pub fn tab_separator(capabilities: PluginCapabilities) -> &'static str { } pub fn tab_line( + session_name: Option<&str>, mut all_tabs: Vec<LinePart>, active_tab_index: usize, cols: usize, @@ -181,7 +186,7 @@ pub fn tab_line( }; tabs_to_render.push(active_tab); - let prefix = tab_line_prefix(palette); + let prefix = tab_line_prefix(session_name, palette); populate_tabs_in_tab_line( &mut tabs_before_active, &mut tabs_after_active, diff --git a/default-plugins/tab-bar/src/main.rs b/default-plugins/tab-bar/src/main.rs index 1f83dcde6..a185ccc33 100644 --- a/default-plugins/tab-bar/src/main.rs +++ b/default-plugins/tab-bar/src/main.rs @@ -64,6 +64,7 @@ impl ZellijPlugin for State { all_tabs.push(tab); } let tab_line = tab_line( + self.mode_info.session_name.as_deref(), all_tabs, active_tab_index, cols, |