Transferring bash functionality to cmd.exe

    For me, like many of you, working with bash and standard Linux utilities is much more convenient and enjoyable than with cmd.exe. However, unfortunately, sometimes the circumstances are such that you do not have to choose an operating system. For example, in my case, the corporate standard is Windows 7. Fortunately, there is a way to make the life of Linux on the Windows command line more comfortable, and we will talk about it below.

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

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

    • Auto completion by pressing Tab. Auto-completion features can be expanded with custom scripts on Lua
    • Paste text from the buffer by pressing Ctrl-V (unfortunately Shift + Insert does not work)
    • Advanced team history. Search by history (Ctrl-R and Ctrl-S). Support for expressions like !!,! and! $
    • Saving Previous Sessions

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

    Downloaded. Installed. It got 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 own Windows counterparts, for example, findstr can be used instead of grep, but you will have to get used to them again, while others have no analogues at all.

    This problem will help us to solve the ready-made set of programs UnxUtils . The set includes many popular command-line tools in Unix and Linux (the full list can be found 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" | gclipyou 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 archive, unzip its contents to some directory and add the path to usr \ local \ wbin \ to the PATH environment variable, because This is where executable files are stored.

    For the laziest, there is a 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.

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

    Also popular now: