irongit
dotfiles/wezterm/utils.lua
24 lines824 BLua
1local wezterm = require("wezterm")
2local mux = wezterm.mux
3local M = {}
4
5--- Spawns a new maximized window and executes the specified command.
6--
7-- This function creates a new window in WezTerm, executes the given command,
8-- and maximizes the window.
9--
10-- Parameters:
11-- args (table): A table containing the command and its arguments to be executed in the new window.
12--
13-- Returns:
14-- wezterm.action_callback: A callback function that, when executed, spawns a new maximized window with the specified command.
15function M.SpawnMaximizedCommandInNewWindow(args)
16 return wezterm.action_callback(function(win, pane)
17 local cwd_uri = pane:get_current_working_dir()
18 local cwd = cwd_uri and cwd_uri.file_path or nil
19 _, _, win = mux.spawn_window({ args = args, cwd = cwd })
20 win:gui_window():maximize()
21 end)
22end
23
24return M