Add PromptInputLine and examples of (re)naming tabs/workspaces

refs: https://github.com/wez/wezterm/issues/522
refs: https://github.com/wez/wezterm/issues/1598
This commit is contained in:
Wez Furlong committed 2023-04-04 21:11:08 -07:00
1 parent b2b5c64aff
commit 336fefb52f
8 files changed
+288 -2

No files matched your search

@@ -48,5 +48,49 @@ config.keys = {
},
},
}
return config
```
## Prompting for the workspace name
{{since('nightly')}}
```lua
local act = wezterm.action
wezterm.on('update-right-status', function(window, pane)
window:set_right_status(window:active_workspace())
end)
config.keys = {
-- Prompt for a name to use for a new workspace and switch to it.
{
key = 'W',
mods = 'CTRL|SHIFT',
action = act.PromptInputLine {
description = wezterm.format {
{ Attribute = { Intensity = 'Bold' } },
{ Foreground = { AnsiColor = 'Fuchsia' } },
{ Text = 'Enter name for new workspace' },
},
action = wezterm.action_callback(function(window, pane, line)
-- line will be `nil` if they hit escape without entering anything
-- An empty string if they just hit enter
-- Or the actual line of text they wrote
if line then
window:perform_action(
act.SwitchToWorkspace {
name = line,
},
pane
)
end
end),
},
},
}
return config
```