evnp / tmex

tmux-execute – a lightweight tmux command & layout composer
MIT License
87 stars 5 forks source link

FR: Flag to specify shell #11

Open marcelarie opened 1 month ago

marcelarie commented 1 month ago

I think it would be really useful to have a flag to specify the shell that will be used to run the commands.

For example"

tmex "$SESSION" --reattach --focus=0 --layout="2{41}" --shell=fish  "cd $REPO_NAME; clear; $EDITOR" "cd $REPO_NAME; clear;" 

Instead of doing something like:

tmex "$SESSION" --reattach --focus=0 --layout="2{41}"  "cd $REPO_NAME; clear; $EDITOR; fish" "cd $REPO_NAME; clear; fish" 
evnp commented 1 month ago

Hey @marcelarie, I really like this idea – thanks! There's an existing --shellless / -s arg (a boolean flag) that I think it would be great to harmonize with.

One thought is that along with a new --shell arg as you suggest, --shellless would remain, and would be exactly equivalent to --shell=none (or --shell none) in the new setup. For simplicity, and for maintaining backwards-compatibility, I think the short form -s should continue to refer to --shellless.

Allowing -s to somehow control both cases is appealing (-s on its own equating to --shellless, and -s fish setting a shell) but I can't see a way of doing this that doesn't introduce ambiguity – is the arg following -s a shell, a layout, or a command? Maybe there's merit in checking whether the arg is an executable command? (eg. if command -v "${argshell}"; then ...) But this starts to seem too nuanced. Very open to your thoughts on this.

I'd welcome a pull request for this if you have the time and are interested, but I'd also be happy to whip something up soon, whichever you prefer. I'm adding a few small quality-of-life features in the coming weeks that this will dovetail nicely with.