Clink Gives CMD.exe Unix Shell Bash Features

Finally, I can use the Windows Command Prompt like Unix thanks to Clink. This CMD.exe extension adds the powerful Unix Bash-style functionality of the GNU Readline library to the Windows command line. If you are a Microsoft PowerShell user, there is also a PSReadLine module available for it. My favorite bash shell for Windows is Cygwin + ZSH + Oh My ZSH.

Command Prompt with Clink
Command Prompt with Clink

Update: March 30, 2016

Bash will be built into the Windows 10 Anniversary update

Windows Command Prompt Tricks

Use either explorer . or start . to open an Explorer window from the current directory.

explorer .

start .

List directory structure. Use the > redirection operator to print the tree structure into a text file.

tree | more

tree /a > c:\tree.txt
  • F1: Pastes the last executed command (character by character)
  • F2: Pastes the last executed command (up to the entered character)
  • F3: Pastes the last executed command
  • F4: Deletes current prompt text up to the entered character
  • F5: Pastes recently executed commands (does not cycle)
  • F6: Pastes ^Z to the prompt
  • F7: Displays a selectable list of previously executed commands
  • F8: Pastes recently executed commands (cycles)
  • F9: Asks for the number of the command from the F7 list to paste

Git for Windows

Git for Windows includes a Bash shell emulator built with MinGW-w64 and MSYS2. Browse the Git for Windows source code repositories.

Cygwin + ZSH + Oh My ZSH

Cygwin + ZSH + Oh My ZSH

This is also a great Windows bash shell solution to give you the power of Unix. After launching Cygwin setup and installing git and zsh, install Oh My ZSH. For more info, see my Cygwin Oh My ZSH Recipe.

Want More?! › ConEmu

ConEmu can be used with any other console application. To add Cygwin + ZSH + Oh My ZSH to ConEmu,

Open ConEmu Settings:

  1. Under Startup › Tasks
  2. Under Predefined tasks, Select {Bash::CygWin bash}
  3. Locate the Commands input and Copy the text. For example, set CHERE_INVOKING=1 & %ConEmuDrive%\Users \admin\Cygwin\bin\sh.exe –login -i - new_console:C:"%ConEmuDrive%\Users\admin\Cygwin \Cygwin.ico"
  4. Select the + sign button to create a new command group task.
  5. Rename the new command group, Bash::CygWin zsh
  6. Paste in the Commands input text copied from Bash::CygWin bash command group in step 3.
  7. Replace sh.exe with zsh.exe. For example, set CHERE_INVOKING=1 & %ConEmuDrive%\Users \admin\Cygwin\bin\zsh.exe –login -i - new_console:C:"%ConEmuDrive%\Users\admin\Cygwin \Cygwin.ico"

Update: August 18, 2016

Bash on Ubuntu on Windows 10 in ConEmu

After installing Oh My ZSH to Bash on Ubuntu on Windows, launch it within ConEmu to make it even better. It is defined as Bash::bash under tasks.

Command Prompt with Clink
ConEmu Settings - Tasks

%windir%\system32\bash.exe -cur_console:p

More info, ConEmu - Using Bash on Windows

Microsoft PowerShell

Another command line option is available when using the Microsoft PowerShell task automation and configuration management framework from Microsoft. PowerShell provides access to WMI, COM and the .NET object model in an interactive and scriptable command line environment. Learning PowerShell is made easier by using its console-based help, like man pages in Unix shells, with the Get-Help Cmdlet. Help contents can be downloaded using the Update-Help Cmdlet. Context help is available with the -online switch to Get-Help.

PowerShell Resources

comments powered by Disqus