-
I am trying to get the tabs to show for instance that i am running "nvim" or any other process. So, for when nothing is running on a terminal window, it should preview probably zsh since it is the underlying process for the terminal window. Should i use the functionalities of wezterm's mux-process? Currently my config looks as follows: local wezterm = require 'wezterm';
local COLOR_BG = "white"
local COLOR_BG_ALT = "#485460"
local COLOR_FG = "white"
local COLOR_FG_ALT = "#ff5e57"
local COLOR_ACCENT = "#1e272e"
local function strip_home_name(text)
local username = os.getenv("USER")
return text:gsub("/home/" .. username, "~")
end
wezterm.on("update-right-status", function(window)
local window_dimensions = window:get_dimensions();
if not window_dimensions.is_full_screen then
window:set_right_status(wezterm.format({{Text=""},}));
return;
else
local date = wezterm.strftime("%a %b %-d %H:%M:%S");
local bat = ""
for _, b in ipairs(wezterm.battery_info()) do
bat = string.format("%.0f%%", b.state_of_charge * 100)
end
window:set_right_status(wezterm.format({
{Text=bat .. " " .. date},
}));
return;
end
end)
wezterm.on("format-window-title", function(tab, tabs)
local zoomed = ""
if tab.active_pane.is_zoomed then
zoomed = "[Z] "
end
local index = ""
if #tabs > 1 then
index = string.format("[%d/%d] ", tab.tab_index + 1, #tabs)
end
local clean_title = strip_home_name(tab.active_pane.title)
return zoomed .. index .. clean_title
end)
wezterm.on("format-tab-title", function(tab, hover)
-- edge icon
-- local edge_background = COLOR_BG
-- inactive tab
local background = COLOR_BG_ALT
local foreground = COLOR_FG
if tab.is_active then
background = COLOR_FG_ALT
foreground = COLOR_BG
elseif hover then
background = COLOR_ACCENT
foreground = COLOR_FG
end
-- local edge_foreground = background
local clean_title = strip_home_name(tab.active_pane.title)
return {
-- { Background = { Color = edge_background } },
-- { Foreground = { Color = edge_foreground } },
{ Background = { Color = background } },
{ Foreground = { Color = foreground } },
{ Text = clean_title },
-- { Background = { Color = edge_background } },
-- { Foreground = { Color = edge_foreground } },
}
end)
return {
enable_tab_bar = true,
adjust_window_size_when_changing_font_size = false,
window_background_opacity = 0.9,
color_scheme = "Jellybeans",
font = wezterm.font("JetBrains Mono", {weight = "Bold", italic = true}),
launch_menu = {
{
args = {"htop"},
},
{
label = "Bash Shell",
args = {"bash"},
},
},
} Thankful for any guidance on how to achieve this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 14 replies
-
#876 is asking for a way to pull process information for a pane. What I use for this sort of thing is configure the Here's an excerpt from my dotfiles; this isn't the full thing because I also have a variation on the shell-integration that is mentioned in these docs in my actual dotfiles, and that is a bit much to recreate here: function _dotfiles_ansi_dequote()
{
# `strip-ansi-escapes` is a utility that ships with wezterm and filters out ansi escape sequences
if hash strip-ansi-escapes 2>/dev/null ; then
echo "$1" | strip-ansi-escapes
else
echo "$1" | perl -pe "s/\\x1b\[[0-9]+(;[0-9]+)*[km]//g"
fi
}
function _dotfiles_set_window_title()
{
local title
title=`_dotfiles_ansi_dequote "$1" | perl -pe "s/;//g"`
case $TERM in
xterm*|rxvt*|Eterm|eterm|aixterm|dtterm)
printf "\033]0;%s\a" "$title"
;;
iris-ansi)
printf "\033P1.y%s\033\\" "$title"
;;
sun-cmd)
printf "\033]l%s\033\\" "$title"
;;
hpterm)
printf "\033&f0k%dD%s" "${#title}" "${title}"
;;
screen*|tmux*)
# screen and tmux window title
printf "\033k%s\033\\" "$title"
# set the tmux pane title too
[[ -n "$TMUX" ]] && printf "\033]2;%s\033\\" "$title"
;;
esac
}
# Run by zsh immediately before we exec a command; we use it to amend
# the window title to show what is running.
function preexec()
{
local cmd
cmd="$1"
case $cmd in
fg*)
# show something more useful than "fg" when we resume a suspended job
local job
read cmd job <<< "$cmd"
if [[ -z "$job" ]] ; then
# the echo is to strip extra whitespace
cmd=$(echo $(builtin jobs -l %+ 2>/dev/null | cut -d' ' -f6-))
else
cmd=$(echo $(builtin jobs -l $job 2>/dev/null | cut -d' ' -f6-))
fi
;;
esac
_dotfiles_set_window_title "$cmd -- ${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}"
} |
Beta Was this translation helpful? Give feedback.
#876 is asking for a way to pull process information for a pane.
I've been resisting this because it assumes that panes are local, and with the multiplexer functionality that isn't guaranteed.
What I use for this sort of thing is configure the
preexec
function in my shell (I usezsh
) so that it emits escape sequences that change the tab title just prior to running commands as I type them in to the shell. Since I use this on most of the systems I use, it also works for me when I log into remote systems.Here's an excerpt from my dotfiles; this isn't the full thing because I also have a variation on the shell-integration that is mentioned in these docs in my actual dotfiles, and that is a b…