Run Command in Another Cygwin Window Without Exiting – How to

bashcygwin;linux

From current cygwin shell, I want to run a command(say, pwd) in another cygwin window, I use:

cygstart /bin/bash pwd

It did spawn a new cygwin window but close immediately. I want the window is still opening and showing the command execution result.

How can I achieve this?

Thanks in advance.

Best Answer

you could wrap this into a simple shell that waits for some input at the end of your command. For example, this one achieves this:

#!/bin/bash
cmd=$*
tmpcmd=/tmp/cygwr.$$
echo "#!/bin/bash" > $tmpcmd
echo "$cmd" >>  $tmpcmd
echo "read line" >>  $tmpcmd

chmod +x $tmpcmd
cygstart /bin/bash $tmpcmd
rm -f $tmpcmd
  • copy this to a file, say ~/cygwrap.sh
  • chmod +x ~/cygwrap.sh and then invoke it, example:

    ~/cygwrap.sh pwd

Related Question