Sample code for calling launcher menu item from CLI #3836
mitchcapper
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The launcher menu is an array of SpawnCommand ( https://wezfurlong.org/wezterm/config/lua/SpawnCommand.html ) elements which offer through configuration for new tabs/windows. There isn't a direct connection to call a launch menu item from the CLI (that I am aware of) but it is possible to work around it pretty easily. We can tap the gui-startup event. We can't modify the parameter passed to gui-startup (a SpawnCommand representing the users initial CLI call) but we can just manually handle the spawning ourselves. If we spawn a window during the event handler the default action is suppressed.
This allows for easily creating say windows shortcuts to specific menu items as well.
How you want to handle the CLI invoking can be adjusted but the simple example below allows overloading of the command itself with any label from the launch menu. For example calling:
wezterm-gui start -- BashCon
. If you run into an issue just run the command from an existing shell with the base wezterm rather than wezterm-gui executable (iewezterm start -- BashCon
). If the issue still isn't obvious uncomment the log line to see what it is finding vs the calling arg. It would be trivial to do things like tack additional command line args onto the pre-defined (if any) launch args for the menu item, or to say require a verb prior to the menu item name so you have to to dowezterm start -- launch_item BashCon
.Here is a full sample config (should work on releases of wezterm from the last few months).
Beta Was this translation helpful? Give feedback.
All reactions