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. However, my favorite bash shell for Windows is still 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 contents by page or line with the pipe | redirection operator. Use the space bar to advance by page or enter key to advance by line. Use Ctrl + C to exit out of the list.

dir | more

dir /s | more

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

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. Here are the steps that worked for me:

  1. Install Cygwin
  2. Launch Cygwin setup and install git and zsh,
    Select Packages Dialog:
    1. Search for git
      Expand Devel
      Select git
      Select git-completion
      Select gitk
    2. Search for zsh
      Expand Shells
      Select zsh
  3. Launch a Cygwin terminal and install Oh My ZSH via curl, if curl is not found, search for and install it similar to zsh above. (visit Oh My ZSH for more info)
  4. I received this message after the install completed:

    Looking for an existing zsh config...
    Using the Oh My Zsh template file and adding it to ~/.zshrc
    Copying your current PATH and adding it to the end of ~/.zshrc for you.
    I can't change your shell automatically because this system does not have chsh.
    Please manually change your default shell to zsh!
  5. I change the default shell to zsh by editing the Cygwin/etc/passwd file replacing all occurrences of /bin/bash with /bin/zsh

    * Your results may vary, I am not responsible if you hose your system.

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 -
  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 -

Update: August 18, 2016
Bash on Ubuntu on Windows 10 in ConEmu

After installing Oh My ZSH to Bash on Ubuntu on Windows, add it to ConEmu to make it even better.

  1. Select the + sign button to create a new command group task.
  2. Name the new command group,
    Bash::Ubuntu zsh
  3. Commands input
    %windir%\system32\bash.exe -cur_console:p
ConEmu – Using Bash on Windows

Published by

Jim Frenette

Web Developer - views here are my own except those taken from people more clever than me.