docs/config/lua/pane/get_foreground_process_info.md
pane:get_foreground_process_info(){{since('20220624-141144-bd1b7c5d')}}
Returns a LocalProcessInfo object corresponding to the current foreground process that is running in the pane.
This method has some restrictions and caveats:
ssh to connect to a remote host, you won't be able to access the name of the remote process that is running.If the process cannot be determined then this method returns nil.
This example sets the right status to show the process id and executable path:
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)
local info = pane:get_foreground_process_info()
if info then
window:set_right_status(
tostring(info.pid) .. ' ' .. basename(info.executable)
)
else
window:set_right_status ''
end
end)
return {}