Can you make Windows command prompt cmd+cygwin?

I want to make my windows command prompt cmd+cygwin. I should be able to run both windows cmd commands and cygwin commands from my windows cmd prompt. If I add C:\cygwin64\bin to my PATH variable i can run some cygwin commands like ls and clear and some more through cmd prompt, but cygwin style paths don't work in this case.

D:\>cd /cygdrive/d
The system cannot find the path specified.

Is there a clean way to do this?

UPDATE:Based on suggestions I tried it in Powershell.

PS C:\GIT_Repo> ls -lrt
Get-ChildItem : A parameter cannot be found that matches parameter name 'lrt'.
At line:1 char:4
+ ls -lrt
+ ~~~~ + CategoryInfo : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

This command works in CMD prompt:

C:\GIT_Repo>ls -lrt
total 752
-rw-rw-r--+ 1 Ashish None 931 Jun 26 23:39 Mp3_Properties.py
-rwxrwxr-x+ 1 Ashish None 763247 Jun 26 23:44 'My_mp3_File.mp3'

Path don't work in Powershell too:

PS C:\GIT_Repo> cd /cygdrive/c
cd : Cannot find path 'C:\cygdrive\c' because it does not exist.
At line:1 char:1
+ cd /cygdrive/c
+ ~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (C:\cygdrive\c:String) [Set-Location], ItemNotFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

Still no success.

4

3 Answers

Answer is YES. I was able to do it with suggestions from @Nathan.Eilisha Shiraini

Following care should be taken:

1=> Add C:\cygwin64\bin to your PATH variable.

2=> All /cygdrive/c paths should be replaced with c:/

C:\>cd C:/Software_Development/Examples
C:\Software_Development\Examples>
C:\Software_Development\CPP>cd ../Examples
C:\Software_Development\Examples>

3=> All the third party softwares should be used from windows installations and not from cygwin.(perl,python etc.). Because cygwin supplied softwares use /cygdrive/c style paths. Cygwin should be used as driver which will trigger windows installed software.

4=> Executables should be executed in windows style ./Executable.o will not work.

C:\Software_Development\CPP>g++ MyTest.cpp -o MyTest.o
C:\Software_Development\CPP>ls
MyTest.cpp -o MyTest.o
C:\Software_Development\CPP>MyTest.o
This program is compiled on windows

5=> All cygwin linux like commands return paths in /cygdrive/c/ style you need to convert them to c:/ wherever necessary.

C:\Software_Development\Examples>which python
/cygdrive/c/Python/Python36/python

Some more commands:

C:\Software_Development\CPP>cat MyTest.cpp
#include<iostream>
using namespace std;
int main()
{ cout << "This program is compiled on windows"; return 0;
}
C:\Software_Development\CPP>rm MyTest.cpp
C:\Software_Development\CPP>

Important to note here is all cygwin software will give you path in /cygdrive/c form which you need to convert them as c:/

TL;DR, no.

The way a file system is organized is extremely different between Windows and Linux, and it does not limit itself to using back- or forward slashes. For instance, only Windows is organized in drives, Linux only has its root directory.

Some Windows commands allow the use of forward slashes in paths, but most use them as the flag prefix (e.g. ping -t is equivalent to ping /t under Windows).


EDIT As suggested by EBGreen in their comment, you can try to use Powershell. I know by experience that it is slightly interoperable with Bash, as long as you don't do anything fancy (or anything at all). You can't do command chaining/piping, file redirections, strings with escaped characters, variables, and the list goes on...

8

Of course it is possible.

As of cygwin version 2.11.0. launched in 2018

When execution of linux command is necessary through windows default Command Prompt simply change the directory to C:\cygwin\bin> (if cygwin is installed on C:) whereas windows user level command line directory remains unchanged.

For example:

After installing cygwin, in windows command prompt as a user you shall execute all windows command like

C:\Users\My Username> where /r C:\\Users\pictures myimage.png

On the other hand you shall execute all linux command at

C:\cygwin\bin>

If you install cygwin at C:/cygwin, to change the command line directory from C:\Users\My Username> to C:\cygwin\bin> simply use windows cd command in command prompt like,

C:\Users\My Username> cd C:/cygwin/bin

and run linux command like,

C:\cygwin\bin> find C:/Users/pictures -name myimage.png

This way you can execute both windows commands in global scope and linux command in path scope from windows default terminal.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like