As a full-stack developer in LAMP, I often play-around with Linux servers.
Unfortunately, there are always some reason that I can’t switch to Linux development machine.
E.g. Windows only printer drivers, Adobe Software, exe…
However, Windows cmd/PowerShell always disgust me for their special syntax.
And I missed Unix-like CLI tools such as (grep
, find
, wget
, curl
, vim
, ssh
…) so much.
Plus you can’t use id_rsa
format in Windows directly (You will need putty, a GUI tool for CLI… and you need to convert all your keys)
So today we will get those lovely tools back, on Windows!
(Does NOT require Windows 10 Ubuntu Bash, should work on any supported version of Windows)
- Install Git for Windows
No matter if you use Git, you will need to install it.
Git for Windows installation includes a very nice Bash environment (In form of MinGW)
https://git-scm.com/During the installation, those options are recommend, otherwise keep the default option.
- Meet the bash shell
Now right click on any folder in Windows Explorer, a nice bash shell is waiting for you
You can right click on the title bar to set windows/font size and other settings.
- Know about the path structure
Bash in Windows is base on MinGW, it’s not an emulator, but a compatibility layer to make Windows environment POSIX compatible.
Maybe too complicated, let’s forgot it. What you need to know first is the path used in this Bash
e.g. To change working directory toC:\Windows\
, you will need tocd /c/windows
(Yes, it’s case Insensitive)
To editC:\Apache\htdocs\phpinfo.php
, you will need tovim /c/Apache/htdocs/phpinfo.php
- What about ssh?
That’s what I need the most.
Firstly, we can now usessh-keygen
to generate our public/private pairs like on Unix.
They will be stored in~/.ssh/
(i.e.C:\Users\Tiger\.ssh like path
)
id_rsa
andid_rsa.pub
works directly without converting in bash!
You can nowssh [email protected]
without the need of external tools!
Of course,git
works well in bash. - Other goodies from Unix
curl
,vim
,ssh
,git
,grep
,find
… works out-out-box
CheckC:\Program Files\Git\mingw64\bin
andC:\Program Files\Git\usr\bin
to see what’s available.You may as well, add your favorite CLI tools to Windows Environment Path.
MinGW bash does pick them up, after a computer restart.Color works,
~/.bashrc
works, tab-completions are awesome just like on Linux.Happy bashing!
3 Replies to “[Windows Bash] Using bash in Windows”