📜 ⬆️ ⬇️

We transfer bash functionality to cmd.exe

I, like many of you, work with bash and standard Linux utilities much more comfortable and more pleasant than with cmd.exe. However, unfortunately, sometimes the circumstances are such that the operating system does not have to choose. For example, in my case, the corporate standard is Windows 7. Fortunately, there is a way to make the life of a Linux user in the Windows command line more comfortable, which will be discussed below.


First of all, when switching from bash to cmd.exe, the inconvenience of the command shell itself is inconvenient. To paste text from the clipboard, you need to reach for the mouse, there are not enough autocompletion options, the history is stored only within one session, besides, Ctrl + R and other options for working with the command history in bash do not work.

Clink will help us to correct the situation. This is an open source utility that extends cmd.exe. Here are some of its features:


')
The authors say that clink was tested only on Windows XP SP3, but I have been using it for a year on Windows 7 and everything is working fine.

Downloaded. Installed. It became better, now cmd behaves almost like bash. But something is still missing. Namely, the usual unix-utilities. Such as cat, ls, tail, diff, grep, less, sort, wget, etc. Some utilities have their Windows counterparts, for example, instead of grep, you can use findstr, but you will have to get used to them again, while others do not have any analogues.

This problem will help us to solve a ready-made set of programs UnxUtils . The set includes many command line tools popular in Unix and Linux (the full list can be viewed at this link ) as well as several additional programs.

In particular, additional programs include pclip.exe and gclip.exe designed to work with the Windows clipboard. For example, like this: pclip | sed "s/string1/string2/g" | gclip pclip | sed "s/string1/string2/g" | gclip pclip | sed "s/string1/string2/g" | gclip can replace all occurrences of string1 with string2 in the text stored in the clipboard.

In order to get all this on your Windows machine, you need to download the UnxUtils.zip archive, unpack its contents into a directory and add the path to usr \ local \ wbin \ to the PATH environment variable, since this is where executable files are stored.

For the most lazy, there is an even simpler way: copy the contents of the usr \ local \ wbin \ directory from the archive to the% WINDIR% \ system32 \ directory on your machine.
Attention! If you decide to do just that, then I do not recommend replacing system files with files of the same name from the archive without a clear understanding of what you are doing.

Everything! It remains only to run cmd and work effectively using your linux experience. Of course there are other ways to achieve the same result, I described one that I find as simple and satisfying as possible all my needs.

Source: https://habr.com/ru/post/177033/


All Articles