3

What I want is to open default shell, then call another and execute a command there.

Was trying something like this:

c:/Windows/System32/bash.exe -c "zsh & zstyle"

or

cmd /k "c:/Windows/System32/bash.exe -c zsh" & zstyle - this open shell but doesn't run a commands

or

c:/Windows/System32/bash.exe -c "zsh -c 'zstyle'"

Currently I am using a cmder/conemu terminal for windows.

AuthorProxy
  • 7,946
  • 3
  • 27
  • 40

1 Answers1

2

Unfortunately, passing a startup to command to zsh with -c and keeping it open for interactive use (with -i) doesn't work.

Disclaimer: The following solutions were tested from a regular Command Prompt (cmd.exe), not cmder/conemu, though I'd expect them to work there too.
To try them from PowerShell (v3+), insert --% as the first argument after (right after bash.exe).

Here's a workaround:

c:/Windows/System32/bash.exe -c "zsh -c 'zstyle' && exec zsh -i"

Note that command zstyle is executed in a different, transient zsh instance, so this approach won't work for commands whose purpose is to modify the environment of the interactive shell that stays open.
If that is a requirement, things get more complicated (this solution courtesy of this answer):

c:/Windows/System32/bash.exe -c "{ { echo 'zstyle'; echo 'exec 0<&3-';} | zsh -i; } 3<&0"

Note, however, that both commands being executed will be printed before their output, if any, is shown, preceded by the prompt - as if the commands had been typed interactively.

Community
  • 1
  • 1
mklement0
  • 382,024
  • 64
  • 607
  • 775