Windows is infamous to make everything as difficult as possible.
Here I write the steps to make the experience of using Windows a bit less of a pain.
cmd.exe is terrible, Powershell is a monstrosity… What can we do?
MSYS2 is a software distro and building platform for Windows
It gives bash and a pacman implementation for Windows. Don't forget to add
ILoveCandy under the misc options of
With it one can easily install
tmux and have a good console.
Just open the Start menu, type “min” and press enter!
This is also a good way to install the GCC and the Clang compilers.
Since Windows expects paths like
c:/Users/Sato/ and Unix expects paths like
/home/Sato the Msys2 shell does path mangling so that windows programs will find what is expected.
For example, one types:
./prg.exe / /c/Users/Sato/Music/
and the passed arguments (
argv in C parlance) are:
C:\msys64\home\Sato\prg.exe C:/msys64/ C:/Users/Sato/Music/
Normally this is fine, but seldom it breaks programs. To disable it one needs to setup an environment variable:
A common example is docker for windows. One probably wants an alias in their
alias docker='MSYS2_ARG_CONV_EXCL="*" docker'
So that Msys2 won't mangle any path.
Few programs, like nodejs, have problems using Msys2. When you execute them the console seems to hang. It happens because they expect the stdout do be a TTY, in other words stdout must follow the terminal interface protocol.
The Mysys2 shell does not:
$ node -p -e 'Boolean(process.stdout.isTTY)' false
Fortunately there is a solution: the program winpty
$ winpty node -p -e "Boolean(process.stdout.isTTY)" true
Let us see in action:
Nothing happens, until you press CTRL-C stopping it.
$ winpty node Welcome to Node.js v13.11.0. Type ".help" for more information. >
Much better! winpty can be installed with pacman.
Seldom one needs to execute a command as superuser.
The simple solution is executing the console as superuser to start other programs.
Press Super + R, write
C:\msys64\msys2_shell.cmd, and press Shift+Ctrl+Enter.
One cannot expect that bash is installed in every Windows, besides in Windows one often needs to press buttons and wait for windows. So… classic bash scripting might not be the best idea.
AutoIt v3 is a freeware BASIC-like scripting language.
Scripting language able of automating the Windows GUI and that compiles in self-contained .exe files.
Windows now have
clip a program to read content from stdin and write in the clipboard. However the help message does not tell anything about the encoding
clip expects. The encoding is
utf-16le, so one needs to use:
iconv -f utf-8 -t utf-16le | clip
Also it can be useful to consider sfk.exe to be able to read from the clipboard (among other things