2022-06-18 02:57:52 +03:00
|
|
|
# `gui-startup`
|
|
|
|
|
2022-06-25 00:58:18 +03:00
|
|
|
*Since: 20220624-141144-bd1b7c5d*
|
2022-06-18 02:57:52 +03:00
|
|
|
|
|
|
|
The `gui-startup` event is emitted once when the GUI server is starting up
|
|
|
|
when running the `wezterm start` subcommand.
|
|
|
|
|
|
|
|
It is triggered before any default program is started.
|
|
|
|
|
|
|
|
If no explicit program was passed to `wezterm start`, and if the
|
|
|
|
`gui-startup` event causes any panes to be created then those will take
|
|
|
|
precedence over the default program configuration and no additional default
|
|
|
|
program will be spawned.
|
|
|
|
|
|
|
|
This event is useful for starting a set of programs in a standard
|
2022-06-18 17:14:07 +03:00
|
|
|
configuration to save you the effort of doing it manually each time.
|
|
|
|
|
|
|
|
This basic example splits an initial window into thirds:
|
2022-06-18 02:57:52 +03:00
|
|
|
|
|
|
|
```lua
|
|
|
|
local wezterm = require 'wezterm'
|
|
|
|
local mux = wezterm.mux
|
|
|
|
|
2022-07-19 17:54:31 +03:00
|
|
|
wezterm.on('gui-startup', function()
|
|
|
|
local tab, pane, window = mux.spawn_window {}
|
2022-06-18 17:14:07 +03:00
|
|
|
-- Create a split occupying the right 1/3 of the screen
|
2022-07-19 17:54:31 +03:00
|
|
|
pane:split { size = 0.3 }
|
2022-06-18 17:14:07 +03:00
|
|
|
-- Create another split in the right of the remaining 2/3
|
|
|
|
-- of the space; the resultant split is in the middle
|
|
|
|
-- 1/3 of the display and has the focus.
|
2022-07-19 17:54:31 +03:00
|
|
|
pane:split { size = 0.5 }
|
2022-06-18 02:57:52 +03:00
|
|
|
end)
|
2022-07-07 16:31:59 +03:00
|
|
|
|
|
|
|
return {}
|
|
|
|
```
|
|
|
|
|
|
|
|
This example creates a default window but makes it maximize on startup:
|
|
|
|
|
|
|
|
```lua
|
|
|
|
local wezterm = require 'wezterm'
|
|
|
|
local mux = wezterm.mux
|
|
|
|
|
2022-07-19 17:54:31 +03:00
|
|
|
wezterm.on('gui-startup', function()
|
|
|
|
local tab, pane, window = mux.spawn_window {}
|
2022-07-07 16:31:59 +03:00
|
|
|
window:gui_window():maximize()
|
|
|
|
end)
|
2022-06-18 02:57:52 +03:00
|
|
|
|
|
|
|
return {}
|
|
|
|
```
|
|
|
|
|
2022-06-18 17:14:07 +03:00
|
|
|
Here's a more elaborate example that configures two workspaces:
|
|
|
|
|
|
|
|
```lua
|
|
|
|
local wezterm = require 'wezterm'
|
|
|
|
local mux = wezterm.mux
|
|
|
|
|
2022-07-19 17:54:31 +03:00
|
|
|
wezterm.on('gui-startup', function()
|
2022-06-18 17:14:07 +03:00
|
|
|
-- Set a workspace for coding on a current project
|
|
|
|
-- Top pane is for the editor, bottom pane is for the build tool
|
2022-07-19 17:54:31 +03:00
|
|
|
local project_dir = wezterm.home_dir .. '/wezterm'
|
|
|
|
local tab, build_pane, window = mux.spawn_window {
|
|
|
|
workspace = 'coding',
|
|
|
|
cwd = project_dir,
|
2022-06-18 17:14:07 +03:00
|
|
|
}
|
2022-07-19 17:54:31 +03:00
|
|
|
local editor_pane = build_pane:split {
|
|
|
|
direction = 'Top',
|
|
|
|
size = 0.6,
|
|
|
|
cwd = project_dir,
|
2022-06-18 17:14:07 +03:00
|
|
|
}
|
|
|
|
-- may as well kick off a build in that pane
|
2022-07-19 17:54:31 +03:00
|
|
|
build_pane:send_text 'cargo build\n'
|
2022-06-18 17:14:07 +03:00
|
|
|
|
|
|
|
-- A workspace for interacting with a local machine that
|
|
|
|
-- runs some docker containners for home automation
|
2022-07-19 17:54:31 +03:00
|
|
|
local tab, pane, window = mux.spawn_window {
|
|
|
|
workspace = 'automation',
|
|
|
|
args = { 'ssh', 'vault' },
|
2022-06-18 17:14:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
-- We want to startup in the coding workspace
|
2022-07-19 17:54:31 +03:00
|
|
|
mux.set_active_workspace 'coding'
|
2022-06-18 17:14:07 +03:00
|
|
|
end)
|
|
|
|
|
|
|
|
return {}
|
|
|
|
```
|
|
|
|
|
2022-06-18 16:34:50 +03:00
|
|
|
See also:
|
|
|
|
* [wezterm.mux](../wezterm.mux/index.md)
|