2022-01-17 21:32:23 +03:00
# SwitchToWorkspace
2022-03-20 02:37:27 +03:00
*Since: 20220319-142410-0fcdea07*
2022-01-17 21:32:23 +03:00
Switch to a different workspace, creating it if it doesn't already exist.
`SwitchToWorkspace` accepts two optional parameters:
* `name` - the name of the workspace. If omitted, a randomly generated name will be chosen.
* `spawn` - a [SpawnCommand ](../SpawnCommand.md ) describing the command that should be started in the workspace if it doesn't already exist. If omitted, the default program will be spawned in the newly created workspace.
```lua
local wezterm = require 'wezterm'
2022-06-25 16:58:10 +03:00
local act = wezterm.action
2022-01-17 21:32:23 +03:00
2022-07-19 17:54:31 +03:00
wezterm.on('update-right-status', function(window, pane)
2022-01-17 21:32:23 +03:00
window:set_right_status(window:active_workspace())
end)
return {
keys = {
-- Switch to the default workspace
2022-07-19 17:54:31 +03:00
{
key = 'y',
mods = 'CTRL|SHIFT',
action = act.SwitchToWorkspace {
name = 'default',
},
},
2022-01-17 21:32:23 +03:00
-- Switch to a monitoring workspace, which will have `top` launched into it
2022-07-19 17:54:31 +03:00
{
key = 'u',
mods = 'CTRL|SHIFT',
action = act.SwitchToWorkspace {
name = 'monitoring',
spawn = {
args = { 'top' },
},
},
},
2022-01-17 21:32:23 +03:00
-- Create a new workspace with a random name and switch to it
2022-07-19 17:54:31 +03:00
{ key = 'i', mods = 'CTRL|SHIFT', action = act.SwitchToWorkspace },
2022-01-17 21:32:23 +03:00
-- Show the launcher in fuzzy selection mode and have it list all workspaces
-- and allow activating one.
2022-07-19 17:54:31 +03:00
{
key = '9',
mods = 'ALT',
action = act.ShowLauncherArgs {
flags = 'FUZZY|WORKSPACES',
},
},
2022-01-17 21:32:23 +03:00
},
}
```