wezterm adjusts
This commit is contained in:
parent
25b072e141
commit
8d6c22b810
1 changed files with 26 additions and 6 deletions
|
|
@ -16,6 +16,11 @@
|
||||||
return 100
|
return 100
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
wezterm.on('format-tab-title', function(tab, tabs, panes, config, hover, max_width)
|
||||||
|
-- Tab indices are 0-based, so add 1
|
||||||
|
local tab_index = tab.tab_index + 1
|
||||||
|
return " :" .. tab_index .. ": "
|
||||||
|
end)
|
||||||
wezterm.on('update-right-status', function(window, pane)
|
wezterm.on('update-right-status', function(window, pane)
|
||||||
-- Each element holds the text for a cell in a "powerline" style << fade
|
-- Each element holds the text for a cell in a "powerline" style << fade
|
||||||
local cells = {}
|
local cells = {}
|
||||||
|
|
@ -25,12 +30,28 @@
|
||||||
-- shell is using OSC 7 on the remote host.
|
-- shell is using OSC 7 on the remote host.
|
||||||
local cwd_uri = pane:get_current_working_dir()
|
local cwd_uri = pane:get_current_working_dir()
|
||||||
if cwd_uri then
|
if cwd_uri then
|
||||||
local cwd = ""
|
local cwd = cwd_uri.file_path
|
||||||
local hostname = ""
|
local home_dir = os.getenv("HOME")
|
||||||
|
-- Replace the home directory path with ~
|
||||||
cwd = cwd_uri.file_path
|
if cwd:sub(1, #home_dir) == home_dir then
|
||||||
hostname = cwd_uri.host or wezterm.hostname()
|
cwd = "~" .. cwd:sub(#home_dir + 1)
|
||||||
|
end
|
||||||
|
local function shorten_path(cwd)
|
||||||
|
local parts = {}
|
||||||
|
-- Split the cwd by '/'
|
||||||
|
for part in string.gmatch(cwd, "[^/]+") do
|
||||||
|
table.insert(parts, part)
|
||||||
|
end
|
||||||
|
-- Shorten all directory names except the last one
|
||||||
|
for i = 1, #parts - 1 do
|
||||||
|
parts[i] = parts[i]:sub(1, 1)
|
||||||
|
end
|
||||||
|
-- Rebuild the shortened path
|
||||||
|
return table.concat(parts, "/")
|
||||||
|
end
|
||||||
|
cwd = shorten_path(cwd)
|
||||||
|
|
||||||
|
local hostname = cwd_uri.host or wezterm.hostname()
|
||||||
-- Remove the domain name portion of the hostname
|
-- Remove the domain name portion of the hostname
|
||||||
local dot = hostname:find '[.]'
|
local dot = hostname:find '[.]'
|
||||||
if dot then
|
if dot then
|
||||||
|
|
@ -60,7 +81,6 @@
|
||||||
'${config.lib.stylix.colors.withHashtag.base02}',
|
'${config.lib.stylix.colors.withHashtag.base02}',
|
||||||
'${config.lib.stylix.colors.withHashtag.base03}',
|
'${config.lib.stylix.colors.withHashtag.base03}',
|
||||||
'${config.lib.stylix.colors.withHashtag.base04}',
|
'${config.lib.stylix.colors.withHashtag.base04}',
|
||||||
'${config.lib.stylix.colors.withHashtag.base04}',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Foreground color for the text across the fade
|
-- Foreground color for the text across the fade
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue