Adrian
Adrian

Reputation: 20068

Execute a command in a new cygwin console

I want to do something similar to this using cmd in windows:

start dir c:\

A new console should open with the output of dir c:.
For Cygwin i tried this:

cmd /c start bash 'ls c:\\'

The first part will open a new console, but I dont know how to output the result in the new console.

Upvotes: 4

Views: 5470

Answers (2)

Timothy Woods
Timothy Woods

Reputation: 300

cygstart is good, but not really meant for what is being asked. You can think of cygstart <filename> as doing whatever would happen if you double-clicked something in Windows Explorer -- which means it can open files in the default program as well as start executables. However, both cygstart ... and cmd /c start ... will lose your nice terminal environment, so I'd recommend using something that starts a new terminal window, such as run mintty.

For example:

man ()
{
    run mintty --title="man $*" bash --norc -c "command man $@"
}

would open man pages in new windows so that you can view them while still working in your current window.

Upvotes: 2

ak2
ak2

Reputation: 6778

You can use cygstart to start a program in a new console. Or run it in one of Cygwin's other terminals: mintty, rxvt(-unicode), xterm.

Upvotes: 4

Related Questions