koekeishiya / skhd

Simple hotkey daemon for macOS
MIT License
6.05k stars 204 forks source link

execute a command with multiple arguments? #319

Closed tjex closed 9 months ago

tjex commented 9 months ago

I've been trying the whole day to get bkmr to spawn in --fzf mode but to no avail...

What I want is along the lines of

alt + cmd - b : /Applications/WezTerm.app/Contents/MacOS/wezterm start zsh -l -c bkmr search --fzf

Other commands work, such as :

alt + cmd - g : /Applications/WezTerm.app/Contents/MacOS/wezterm start zsh -l -c gopass

I think this is to do with the -c flag taking the following argument as a command, but then setting the subsequent string to $0, as mentioned here. But I don't really know what that means, if it's actually what's causing my issue, or how to circumvent it haha.

In any case, I see a window flash up and then terminate.

I get this output in err log:

16:43:36.808  ERROR  wezterm_mux_server_impl::local > writing pdu data buffer: Broken pipe (os error 32)

I can hack it by getting skhd to invoke a script with zsh, but its not the behaviour I want as the initial program titles the window, meaning that the initial title is zsh, meaning my rule to place the window of bkmr will not work`.

That's the script...

#! /usr/bin/env zsh

bkmr search --fzf

Which gets launched with this command

alt + cmd - b : /Applications/WezTerm.app/Contents/MacOS/wezterm start zsh -li ~/.config/skhd/bkmr.sh

So, does anyone know a way around this or why it doesn't work?

tjex commented 9 months ago

So of course, after posting, I came to the solution. Good for the next person!

The reason is that the -c flag will not see multiple arguments as belonging to the same command. They then need to be wrapped in quotes:

alt + cmd - b : /Applications/WezTerm.app/Contents/MacOS/wezterm start zsh -l -c "bkmr search --fzf"

Thing is I swear I tried this at some point during the day today... But it's a blur 🫨