Cygwin Windows Is Searching For Mintty Missing

Instructions to obtain ZSH on a windows environment, without the input funny business presented by some other attempted solutions.

Aug 11, 2011 - MinTTY - here. It makes Cygwin entirely usable on Windows. I would be lost without it. Based on the original PuTTY code, but integrates straight. I have Cygwin terminal and am trying to set it up on my PC. I run windows 8 and when I try to open Cygwin terminal I receive attached pop up, 'searching for mintty, cannot locate'. In Cygwin, it is installed as the default 'Cygwin Terminal'. For MSYS (old), select the msys-mintty package in the installer. (Or from MinGW, install the package with mingw-get install mintty.) For MSYS2, mintty is installed by default, or it can be installed later with the command pacman -S mintty.

The final result is ZSH running on a mintty terminal, emulated by cygwin, and being handled by the popular cmder.

Why is this here?

Referring back to comment #1, the argument that MDI should be the business of the window manager would work better if the application actually let the window manager do so. Mintty (at least when used with Cygwin) doesn't combine entries in the Windows 7. Oct 17, 2018 For WSL get the latest version here. Cygwin or msys2 usually update mintty very quickly - so just update with their updater, or build it yourself. And for git-for-windows you'll have to wait for their next release (there's a chance a recent msys2 mintty binary will work on recent git-for-windows, but you're on your own there).

For the benefit of myself and others. I've already followed these instructions twice. It took me hours to figure all this out, maybe someone else can save a few.

What exactly is covered?

  • Installing and setting up cmder
  • Installing and setting up cygwin with a package manager
  • Configuring Mintty colors, fonts, and a few other settings
  • Installing zsh, oh-my-zsh, a nifty plugin, and adding a color theme.
  • Configuring the usage of Dir_colors (albeit not in detail), as well as powerline fonts for fancy symbols
  • [optional] Generating a fancy promptline using a vim plugin (since I use vim)
  • Correcting input issues popular python, nodejs, and other language libraries may face... in a very simple way.

While there is a lot of detail here, the ETA to follow these instructions with reasonable pace is ~1hr, especially if you skip a lot of the vim / dir_colors / extra plugin stuff (or save it for another time). I tried to present this in a way that covers the essentials first and cosmetics later.

1. Cygwin setup:

  1. This is straight forward and simple. Download Cygwin.
  2. Run the installer. When it asks for packages, search for 'wget' and make sure that it is selected for install (it will have a version number displayed when set to). Only download the bin, no need for src.
  3. Finish installing. Launch the cygwin terminal from the start menu or the batch file from C:cygwin64
Cygwin

We're going to setup a package manager for cygwin now. Normally if you wanted more packages you'd have to re-run the installer - which means you have to keep it around for later. I don't like that option, so I found apt-cyg. Works like it sounds: apt-get for cygwin!

  1. Run the following to download apt-cyg with wget, install it into the bin of cygwin, and then install a few important commands. Note, you don't need gdb, vim, or dos2unix. I personally use all 3 and will be setting up vim, so I'm grabbing them now. Explore the cygwin packages and grab what you want!NOTE if you run into any line ending issues from here out, scroll down to 'I can't run upgrade oh my zsh' and read
  1. If you want your home folder to be your user's folder, you need to edit /etc/nsswitch.conf. You can do this in the text editor you just downloaded, or type explorer /etc to open the root directory to edit the file in wordpad.
  2. Add this line to the bottom: db_home: windows
Mintty

That's it for cygwin, you can close the terminal. Unless you are adding more packages with apt-cyg, you'll probably not be touching cygwin much more. It's mostly the backbone of this little operation. Now onto cmder, which is the terminal emulator of choice for this guide.

2. CMDER Setup:

  1. Download and install some or all of the powerline fonts. I only use Hack in this guide, so feel free to stick to this. Powerline fonts, for the uneducated, are patched fonts that include some fancy symbols related to git and such. You don't need this, but it's a plus!
Searching
  • 'There's a install.ps1 in the folder. Set execution policy and run it.' (Thanks @yiufung)
  1. Download cmder to get started (the full version!). This is a conemu derivative to run shells inside of. It's flexible and highly customizable, which tends to make it desireable. Features a quake-style drop down shell if you're that kind of person, but more importantly plays really nice with keyboard interactions.
  2. Unpack cmder to a desired location, this is where you'll be keeping cmder permenantly, so pick a cozy spot. Run cmder.exe.
  3. Right click the tab bar of cmder to open the settings. We're going to tweak a few things. Tweak as you like of course.
    1. Under Main (Check General > Fonts if missing - Thanks @SturmB!) we're going to set the font for non-mintty terminals, just for consistency: Hack, Size 16, Uncheck the option for an alternative font.
    2. Under Size&Position we're going to tweak the size of the final window. This applies for the quake style drop down too, which I'm going to lead you into setting up. Set width to 95%, height 75% (be sure to type the %!).
    3. Under Quake, make sure it's turned on!
    4. Under Confirm, turn off the new console / tab dupping confirms. Personally, I don't like them.
    5. IMPORTANT If anything, don't skip this setting: under Tasks, hit the '+' button to create a task that looks like this:
    1. Under Keys and Macros, here are my settings. Tweak as you like:
    1. Under Keyboard check 'Install keyboard hooks' (Might now be called Support special hotkeys if missing - Thanks @SturmB!)
    2. Under Paste make sure each mode is in 'Multi-line'. This only affects cmd / non-mintty terminals from what I've seen, but is pleasent to have set for when not using mintty.
  4. Save settings and hit Win+Down, run your task. Tada you have a ConEmu running cygwin, running mintty. Wonderful. This is what we'll be using to tweak from here out! If you're prompted to generate configuration files, feel free to. If you keep following, I'll be providing my configuration which you can poke around. We're also about to overwrite the default .zshrc with the oh-my-zsh one, so hold out on tweaking that!

3. Setting up oh-my-zsh and plugins

You're already running zsh, but now we're going to add a manager to handle plugins, updating, and themes. Not the most critical stuff, but this is the reason I went through all this trouble - might as well pay it off!

  1. Install oh-my-zsh the manual way. This is well down the page under Advanced Topics. Here's my summary:
  1. Close the current terminal and open a new one to load up oh-my-zsh. If it prompts you to update, do it.
  2. If you have a theme file and a .zshrc, now is the time to copy that over (~/.zshrc and ~/.oh-my-zsh/themes/). You can find mine on my GitHub if you would like a starting point.
    • Realize it does a few things like source a dir_colors file, add ssh keys on login, adds the vim generated promptline, and utilize my personal theme (also in that repo). (It's also subject to change!) Be sure to follow step 6 or remove the related lines from the .zshrc if you use mine!
    • Alternatively, feel free to also just edit the .zshrc generated by oh-my-zsh and pick a theme from one of the defaults for yourself! Oh-my-zsh provides samples online, google it.
  3. Install any oh-my-zsh plugins now. More information on the repo! My favorite is zsh-syntax-highlighting. If you would like that plugin, follow the link and install with the oh-my-zsh package manager guide. Quick tip: This plugin only works if it is loaded last in your .zshrc's plugins list. Yes, I know, how odd.
Cygwin Windows Is Searching For Mintty Missing

4. Mintty settings

This one's short, but this is where we configure mintty's cursor, font, and other stuff. Feel free to poke around.

  1. Right click inside your terminal.
  2. Hit options.
  3. Under text change the font to 'Hack' (or your powerline font of choice). Choose your font size (I like 9).
  4. When you're done poking around the rest of the settings (like cursor), hit Apply and Save.

5. Fixing input issues for python, node, and friends.

I had issues using input libraries from NodeJS and such. I was confused how Git Bash was able to function just fine, yet mintty was failing. The trick? Git Bash aliases node, python, and others to use winpty. Follow along to install winpty and setup the aliases. If you want more information, be sure to stop and read the repo!

  1. Download the release from here: https://github.com/rprichard/winpty
    • This means navigating to their releases and downloading the artifact (Cygwin tar, choose the correct binary for your platform i.e. x64)
  2. cd <path-to-extracted-files>
  3. Copy the needed files for installing: cp -an ./bin/* /usr/bin/. and cp -an ./lib/* /usr/lib/.
  4. Set permissions for the files with winpty at the start: chmod 755 /usr/bin/winpty* and chmod 755 /usr/lib/winpty*
  5. Ensure you have alias'd in your .zshrc: 'node = winpty node.exe'
    • Repeat for any other problematic programs like: ipython php php5 psql python2.7
    • If you want to see how and what GitBash does it this for, go to your cmder's install directory and open: vendorgit-for-windowsetcprofile.daliases.sh

6. Dir Colors, Vim, and the fancy promptline

This section is not very detailed as we're now talking about aesthetic stuff. Look at my github for my configuration files and tweak as you like. Make sure you add in the needed references inside your .zshrc, like using dir_colors and sourcing the prompt line's .sh file. This is what I'm doing with them:

Mintty For Windows 10

  1. Copy your minttyrc and dir_colors files into their needed spots (see my github for examples, or google!): ~/.minttyrc and ~/.dir_colors
  2. Copy your vimrc into ~/.vimrc and install vundle: git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
  3. Launch vim and run :PluginInstall followed by :PromptlineSnapshot ~/.shell_prompt.sh airline to generate the nifty looking powerline prompt script (this needs to be sourced in .zshrc).

I can't run upgrade_oh_my_zsh

Cygwin Windows Is Searching For Mintty Missing Persons

I ran into this once, and it was due to line endings being in dos instead of unix. This may have been because of a gitconfig setting or an issue with the repo -- I'm going to say it was me. If you run into line ending issues for anything, try this:

  1. Verify this is the issue by checking the file format. For upgrade_oh_my_zsh this means the issue is inside ~/.oh-my-zsh/tools/upgrade.sh.
    • I do this by opening the file in vim, where the filetype is displayed on the powerline. If the type is utf-8[dos], you got carriage returns (not desired here).
  2. Install dos2unix (man page) with apt-cyg install dos2unix. This is a simple utility to convert the line endings of a file.
  3. To convert a file just run dos2unix <path to file>. In this case, dos2unix ~/.oh-my-zsh/tools/upgrade.sh.

Recently, Microsoft has made the first stable release of Windows Terminal, anew terminal program for Windows 10. Windows Terminal allows you to add and usemultiple shells, like Windows PowerShell, the old command prompt, and any shellin your Windows Subsystem for Linux (WSL) environments. It also provides waymore features and customization options than the old Windows console hostconhost.exe, which has been used for command prompt and WSL.

This post will instruct you to add other shell executables to Windows Terminal,such as the shell you installed for Cygwin or GitBash if you have Git for Windows. By doing this,you can access a Unix shell and potentially other Unix programs within WindowsTerminal without the need for WSL.

The main purpose of this post is to show you how to use your Cygwininstallation or Git Bash in Windows Terminal if you happen to have theminstalled. It is not intended to recommend Cygwin or Git Bash as WSLalternatives, though if you are interested, you may definitely try them.

The steps for Cygwin and Git Bash slightly differ, so I will first introducethe method for Cygwin, then mention what is different in the method for GitBash.

Mintty download windows 10

Steps for Cygwin

For the following steps, it is assumed that you have Bash installed in Cygwin.It should be possible to use other shells, but your configuration file willlook differently from what is shown here, so please pay attention to that.

  1. Download Windows Terminal from MicrosoftStore.

  2. Open Windows Terminal. You can find the button that opens the drop-down menuon the top, and the menu contains multiple profiles. We will create a newprofile for Cygwin’s shell.

  3. In the drop-down menu, choose “Settings”. This will open up theconfiguration file for Windows Terminal. If you scroll down a little bit,you will see the profiles key and the list array under it. This is wherethe new profile will be added to.

    The basic attributes for a profile are:

    • guid: A unique identifier for the profile

    • name: The profile’s name

    • commandline: The command to start the shell used for this profile

  4. The unique identifier in guid can be any 128-bit UUID that does not repeatany existing one in the configuration file. Please notice that you cannotreuse the identifier for a deleted preset profile. For instance, even ifyou never use the Azure Cloud Shell and deleted its profile, you should notuse that profile’s guid for any new profile.

    After all, this should not be a problem because there are many ways to get aUUID:

    • Run the uuidgen program in Cygwin
    • Search for UUID generators online and use one of them
    • Simply use the UUID I generated for the demo, which isa1f2ceb2-795d-4f2a-81cc-723cceec49c0
  5. Now, you need to know the command line used to start Cygwin’s shell.

    First, find your Cygwin installation path. By default, it is C:cygwin64for the 64-bit version. The bash.exe executable in a Cygwin installationshould be placed in the bin folder under Cygwin’s installation path.Therefore, the absolute path to the executable file isC:cygwin64binbash.exe by default.

    For Bash in Cygwin, you need to start bash as an interactive login shell;otherwise, you will encounter the “command not found” error when executingbasic commands like ls. This is because the file /etc/profile, whichadds Cygwin’s /usr/bin and /usr/local/bin directories to the PATHenvironment variable, is not executed for non-login shells. An interactivelogin shell can be started with -i -l flags. If you are using anothershell, please confirm the way to get Cygwin’s /usr/bin and/usr/local/bin into PATH for your shell.

    Therefore, the full command to run Bash in Cygwin isC:cygwin64binbash.exe -i -l. If you have installed Cygwin to anon-default path and/or want to use another shell, then please change thecommand accordingly.

    Finally, the configuration file accepts the forward slash / as the pathcomponent separator, so you can replace every backslash in the commandwith /. For instance, the above command will be changed toC:/cygwin64/bin/bash.exe -i -l. If you want to use the backslash instead,you have to escape it by adding another backslash, causing the command tobecome C:cygwin64binbash.exe -i -l.

  6. At this point you have collected all information needed for the new profile,so it’s time to add it to the configuration file:

    The order of the profiles in the configuration is the same as the order inwhich they are shown in Windows Terminal. Here, because I want it to be thefirst entry, I put it before every other profile. If you are not adding itas the last profile, then don’t forget the trailing comma; otherwise, makesure the trailing comma is not there, and add a comma after the profile thatwas originally the last one.

  7. Save the file. If your configuration file is valid, then you should now seethe new profile added to the menu. When you choose it, you should see Bashrunning in a new terminal tab.

Steps for Git Bash

Mintty Cygwin

The steps to add Git Bash differ at only two places:

  • You cannot run uuidgen in Git Bash to obtain a unique identifier. However,you can still use any alternative method mentioned above to get one.

  • If you installed Git for Windows at C:Program FilesGit, then the absolutepath to the Git Bash executable is C:Program FilesGitbinbash.exe.

Removing “Process Exited With Code x” Messages

Mintty For Windows

If the last command you ran before quitting the shell using exit or Ctrl-Dfinished with a non-zero exit status, you might see something like what thescreenshot shows. Sometimes this can even happen if you did not run anycommand, which is likely to be caused by a command in initialization scriptslike .bashrc.

Cygwin Searching For Mintty

These messages must be dismissed manually. To stop Windows Terminal fromgenerating them, add an 'closeOnExit': 'always' option to the new profile inthe configuration file. Don’t forget, if this option is the last line for theprofile, you need to make sure a comma exists at the end of the previous line.

Setting Default Windows Terminal Profile

Cygwin Mintty Config

There is a defaultProfile option in the configuration file, which allows youto choose the default shell when a new terminal window or tab is opened. Thedefault profile should be specified by its guid.