docs: add basename to get_foreground_process_name examples

refs: #1421
This commit is contained in:
Wez Furlong committed 2021-12-24 13:09:31 -07:00
1 parent 4a01bf9bf2
commit e3be779477
2 files changed
+16 -2

No files matched your search

+8 -1
View File
@@ -35,9 +35,16 @@ This example places the executable name in the tab titles:
```lua
local wezterm = require 'wezterm'
-- Equivalent to POSIX basename(3)
-- Given "/foo/bar" returns "bar"
-- Given "c:\\foo\\bar" returns "bar"
function basename(s)
return string.gsub(s, "(.*[/\\])(.*)", "%2")
end
wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width)
local pane = tab.active_pane
local title = pane.foreground_process_name .. " " .. pane.pane_id
local title = basename(pane.foreground_process_name) .. " " .. pane.pane_id
local color = "navy"
if tab.is_active then
color = "blue"
@@ -19,8 +19,15 @@ This example sets the right status are to the executable path:
```lua
local wezterm = require 'wezterm'
-- Equivalent to POSIX basename(3)
-- Given "/foo/bar" returns "bar"
-- Given "c:\\foo\\bar" returns "bar"
function basename(s)
return string.gsub(s, "(.*[/\\])(.*)", "%2")
end
wezterm.on("update-right-status", function(window, pane)
window:set_right_status(pane:get_foreground_process_name())
window:set_right_status(basename(pane:get_foreground_process_name()))
end)
return {