Skip to content

Instantly share code, notes, and snippets.

@rkitover
Last active December 24, 2019 23:18
Show Gist options
  • Save rkitover/d008324309044fc0cc742bdb16064454 to your computer and use it in GitHub Desktop.
Save rkitover/d008324309044fc0cc742bdb16064454 to your computer and use it in GitHub Desktop.
How to Install MSYS2

How to Install MSys2

Download it, get the 64 bit build:

https://www.msys2.org/

Download and install the Hack font, you want the -ttf.zip:

https://github.com/source-foundry/Hack/releases

If you just need unix tools, you want the MSYS shell, if you are going to build native software for windows you also want the MINGW64 shell (and possibly the MINGW32 shell for 32 bit builds) you can switch between these in a shell session as well, this is controlled by the MSYSTEM environment variable.

To make a quicklaunch shortcut on your taskbar, set the properties to something like this:

Object: C:\msys64\usr\bin\mintty.exe -e /bin/sh -c "MSYSTEM=MINGW64 /bin/bash -l"
Working Directory: %USERPROFILE%
Icon: C:\msys64\msys2.ico

Add a shortcut key if you like.

Go to Control Panel -> System -> Advanced system settings -> Environment Variables

Set HOME to C:\users<your-id> or whatever your windows user profile directory is.

Set the MSYS variable to:

winsymlinks:nativestrict export wincmdln

Set MSYS2_PATH_TYPE to inherit.

Make sure to click OK and then Apply.

Open up an MSYS shell and update everything:

pacman -Syu

if it tells you to kill the terminal and restart the command, do that, until there are no more updates.

Install an editor such as vim:

pacman -S vim tmux git tree

to search for packages:

pacman -Ss <keyword>

Edit /etc/nsswitch.conf and make sure it has this line:

db_home: windows

Kill the terminal and restart, you should be in your windows user profile directory which is now your home.

Set up your .bashrc or whatever you use. You will want this line in it most likely:

alias ls="ls -h --color=auto --hide='ntuser.*' --hide='NTUSER.*'"

this will make your new home directory look more pleasant.

To configure the terminal to something more reasonable, put this .minttyrc in your home:

https://gist.github.com/rkitover/6dafafcba541db1b1935035e5bbdf998

this uses the Tango Dark color scheme which is usually now the standard on Linux desktops.

That's pretty much it, I'll have some tips below.

I have a prompt for bash for msys2 you may like:

https://github.com/rkitover/bash-msys2-prompt-simple

If you want install an sshd, use this:

https://gist.github.com/samhocevar/00eec26d9e9988d080ac

TIPS

To copy a file to the clipboard for pasting, you can do e.g.:

cat ~/.bashrc > /dev/clipboard

mintty has no tiling options, but just use the windows tiling shortcuts.

To get the same effect as terminal tabs, use Groupy from Stardock and configure it to automatically group the same windows.

to switch between environments, e.g. from MSYS to MINGW64, just do this:

export MSYSTEM=MINGW64
exec bash -l

When calling cmake in a MINGW shell pass in -G 'MSYS Makefiles'.

Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment