-
Currently, there are only the build-in options to spawn a new window in the default workspace or a named workspace: wezterm cli spawn --new-window -- top # spawns in default workspace
wezterm cli spawn --new-window --workspace foo -- top # spawns in 'foo' workspace It would be great to spawn in the current workspace, perhaps like this: wezterm cli spawn --new-window --workspace current -- top I've tried I've been having a look at This feature is enough for me to run my own fork of it, so if anyone had any pointers as to how to replace the default workspace in It is very useful to be able to spawn a program into the current workspace without having to name it (debugger, email, top, even just another shell). let workspace = self
.workspace
.as_deref()
.unwrap_or(
config
.default_workspace
.as_deref()
.unwrap_or(mux::DEFAULT_WORKSPACE),
)
.to_string();
let size = config.initial_size(0, None);
let spawned = client
.spawn_v2(codec::SpawnV2 {
domain: self
.domain_name
.map_or(SpawnTabDomain::DefaultDomain, |name| {
SpawnTabDomain::DomainName(name)
}),
window_id,
command: if self.prog.is_empty() {
None
} else {
let builder = CommandBuilder::from_argv(self.prog);
Some(builder)
},
command_dir: resolve_relative_cwd(self.cwd)?,
size,
workspace,
})
.await?; |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
another idea I had was to update the {
key = "k",
mods = "SUPER",
action = wezterm.action_callback(function()
-- update.wezterm.default_workspace.here
return act.ShowLauncherArgs({ flags = "FUZZY|LAUNCH_MENU_ITEMS" }),
end)
},
|
Beta Was this translation helpful? Give feedback.
-
Trying to get the current active workspace, but the workspace that's returned is whichever workspace is active when wezterm starts up or reloads the config. local function spawn_window(label, path, workspace, cmd)
if workspace == "current" then
workspace = wezterm.mux.get_active_workspace()
end
local args = { "wezterm", "cli", "spawn", "--new-window", "--workspace", workspace, "--" }
for _, c in ipairs(cmd) do
table.insert(args, c)
print(args)
end
return {
label = label,
cwd = path,
set_environment_variables = {
PATH = env_paths,
},
args = args,
}
end
config.launch_menu = {
spawn_window("posts", tjex_site .. "src/content", "current", { "zk", "list" }),
} |
Beta Was this translation helpful? Give feedback.
-
We're also so close, considering there is already {
key = "e",
mods = "LEADER",
action = act.SpawnCommandInNewWindow({
args = { "aerc" },
}),
}, |
Beta Was this translation helpful? Give feedback.
-
Baked an intermediary solution, but it can't handle more complex envocations yet, like As far as I know theres no way to pass local wezterm = require("wezterm")
local act = wezterm.action
local paths = require("paths")
local env_paths = paths.env_paths()
local M = {}
local choices = {
{ id = "aerc", label = "aerc" },
{ id = "zk list", label = "zk list" },
}
local function split_on_whitespace(input)
local result = {}
for word in string.gmatch(input, "%S+") do
table.insert(result, word)
end
return result
end
M.launch_in_current_workspace = function(window, pane)
window:perform_action(
act.InputSelector({
action = wezterm.action_callback(function(inner_window, inner_pane, id, label)
if not id and not label then
wezterm.log_info("cancelled")
else
local cmd = split_on_whitespace(id) -- convert string to table
wezterm.log_info("you selected ", id, label)
inner_window:perform_action(
act.SpawnCommandInNewWindow({
set_environment_variables = {
PATH = env_paths,
},
args = cmd,
}),
inner_pane
)
end
end),
choices = choices,
fuzzy = true,
fuzzy_description = "Launch in current workspace.",
}),
pane
)
end
return M |
Beta Was this translation helpful? Give feedback.
-
final solution is posted here |
Beta Was this translation helpful? Give feedback.
final solution is posted here
#6395