Create the same Linux operating environment on Windows

Source: Internet
Author: User

In the previous article, I introduced a collection of tools that I used in the Gnu/linux graphical interface environment. The basic aim is to maximize the efficiency of computer operation under the condition of ensuring the minimum system resources. Such a combination of tools, such as the Swiss Army Knife general, concise, efficient, full-featured. How do you implement similar operating practices under Windows systems? such as the Gnu/linux command line tool and graphical interface software, similar to the Sawfish window manager functions, as well as multi-desktop. This article will introduce my own solution.

First, to be able to enjoy the convenience and efficiency of the command-line tools under the Gnu/linux system, I installed Cygwin under Windows. Cygwin is a UNIX-like simulation environment that runs on the Windows platform and is a free software developed by Cygnus Solutions Corporation. Cygwin provides a UNIX emulation DLL and a variety of packages built on top of it that can be found on Linux systems, providing good support for versions above Windows XP SP3. In the old version of Cygwin, the terminal program is based on the Cmd.exe of Windows, which cannot be set for font, color style, etc. At present, the Mintty terminal program provided by Cygwin can be well personalized, especially can be configured as solarized color style, with certain vision protection function. This configuration can be downloaded here. It offers both tonal and dark tones in the form of a bash script. Simply add the style settings script to ~/.BASHRC:

SOURCE ~/%your directory%/sol.light
~/%your Directory%/sol.dark

Next, you need to explain how Cygwin is used. In addition to Gnu/linux's command-line tools, Cygwin provides a fairly rich X-Window graphical interface program, such as Emacs, Octave. Furthermore, the stability of these GUI programs has been greatly improved compared to the old version of Cygwin many years ago, and they can be used as a daily prerequisite software. Thinking back a few years ago, I need to separately install for Windows compiled emacs, Octave, Gnuplot, Maxima, texlive, and other tools, there is always a certain problem of collaboration between them. Now, all of these software can be run in a unified cygwin/x environment, the path name, the file name is also consistent with gnu/linux habits, so used and in the original Gnu/linux is the same. In order to use these GUI software, I will cygwin the X Windows Server Xwin under Windows as an automatic add-on for the Windows system and will start automatically after logging in. There are two ways to create a startup item. One is to run the Startxwin command:

C:\cygwin64\bin\run.exe--quote/usr/bin/bash.exe-l-C "CD; Startxwin "

The benefit of this approach is that when X server starts, the content in ~/.XINITRC is automatically run. In this way, you can automatically start the common software such as Mintty, Emacs. However, the method is currently unable to successfully start X server. So the second way to run the Xwin command is to use:

C:\cygwin64\bin\run.exe--quote/usr/bin/bash.exe-l-C "CD; Xwin-multiwindow-clipboard "

This method does not read ~/.XINITRC files, only in ~/. The right-click menu item for the system tray icon is set in XWINRC. Therefore, you cannot set up programs that start with X server.

With the many command-line tools and graphical interface software that Cygwin brings gnu/linux, how do you implement features like the Sawfish window manager in a real gnu/linux environment? For example:

    • Start a specific program with the shortcut key, but if the program has started before starting, then the main window will be transferred to the foreground;
    • Use shortcut keys to manipulate Windows, such as maximize, minimize, move, place all window front ends, and so on.

Fortunately there is autohotkey this software, the above-mentioned sawfish features can be used to simulate. Through configuration, I have implemented the following features:

    • Swap case LOCK Key The CAPS lock and the left control key are necessary for people who often use Emacs.
    • To start the shortcut key settings for a frequently used program:
      • Win+1:cygwin Mintty Terminal Program
      • Win+2:total Commander File Manager
      • Win+3:emacs
      • Win+4:stardict Electronic Dictionary
      • Win+5:firefox Browser
    • Window operation:
      • Win+m: Maximize Window
      • Win+r: Window Restore
      • Win+i: Minimized window
      • Ctrl+alt+j,l,i,k: Left, right, up, down move window
      • Win+left,right,up,down: Moves the window left, right, up, down until it touches another window or screen boundary
      • Win+c: Let the window be in the center of the screen
      • win+=: Increase window width
      • win+-: Decrease Window width
      • win+shift+=: Increase window height
      • win+shift+-: Decrease Window Height
      • Win+shift+h: maximizes the window horizontally until the window touches another window or screen border
      • Win+shift+v: Vertically maximizes the window until the window touches another window or screen boundary
      • Win+t: Make the window above other windows and restore its original level
      • Win+k: Close Window
      • win+: Displays the ahk_class of the current window, which is useful for matching the window

The script for the above configuration is as follows:

#NoEnv; Recommended for performance and compatibility with the future AutoHotkey releases. Sendmode Input; Recommended for new scripts due to it superior speed and reliability. Setworkingdir%a_scriptdir%; Ensures a consistent starting directory.; Swap caps Lock and left Control#ifwinactive+capslock::capslockcapslock::controlsettitlematchmode 2; Cygwin mintty terminal#1::ifwinexist ahk_class mintty{winactivate}else{Run C:\cygwin\bin\mintty.exe winwait ahk_cl Mintty Winactivate}return; Total Commander#2::ifwinexist Total Commander 7.56a{winactivate}else{Run C:\totalcmd\TOTALCMD. EXE winwait Total Commander 7.50a Winactivate}return; emacs#3::ifwinexist [email protected]{Winactivate}return; Stardict#4::ifwinexist King winactivate}else{Run, C:\Program files (x86) \stardict\stardict.exe, C:\Program files (x8 6) \common Files\gtk\2.0\bin winwait stardict Winactivate}return; Firefox#5::ifwinexist ahk_class mozillawindowclass{winactivate}else{Run C:\program Files (x86) \mozilla Firefox\firefox.exe winwait ahk_class mozillawindowclass Winactivate}return; Maximize Window#m::winmaximize, Areturn; Minimize Windows#i::winminimize, Areturn; Restore Window#r::winrestore, Areturn; Move window Left^!j::wingetpos, X, Y,,, Awinmove, A,, X-10, Yreturn; Move window Right^!l::wingetpos, X, Y,,, Awinmove, A,, x+10, Yreturn; Move window Up^!i::wingetpos, X, Y,,, Awinmove, A,, X, Y-10return; Move window Down^!k::wingetpos, X, Y,,, Awinmove, A,, X, Y+10return; Move window left Most#left::wingetpos, X, Y, W, H, A; Winmove, A,, Ywinmove, A,, 0, Yreturn; Move window Right Most#right::wingetpos, X, Y, W, H, Awinmove, A,, A_screenwidth-w, Yreturn; Move window top Most#up::wingetpos, x, Y, W, H, Awinmove, A,, X, 0Return; Move window down Most#down::wingetpos, X, Y, W, H, Awinmove, A,, X, a_screenheight-h-40Return; Center Window#c::wingetpos, X, Y, W, H, A; Winmove, A,, (a_screenwidth-72)/2-W/2 + A_SCREENHEIGHT/2-H/2winmove, A,, A_SCREENWIDTH/2-W/2, (a_screenheight-40)/2-H/2 + 40Return; Increase window Width#=::wingetpos, X, Y, W, H, Awinmove, A,,,, w+10, Hreturn; Decrease window Width#-::wingetpos, X, Y, W, H, Awinmove, A,,,, W-10, Hreturn; Increase window Height#+=::wingetpos, X, Y, W, H, Awinmove, A,,,, W, H+10return; Decrease window Height#+-::wingetpos, X, Y, W, H, Awinmove, A,,,, W, H-10return; Expand Window Horizontally#+h::wingetpos, X, Y, W, H, A; Winmove, A,, a_screenwidth-72, Y, Hwinmove, A,, 0, Y, A_screenwidth, Hreturn; Expand Window Vertically#+v::wingetpos, X, Y, W, H, A; Winmove, A,, X, 0, W, A_screenheightwinmove, A,, X, 0, W, A_screenheight-40return; Toggle window on Top#t::winset,alwaysontop,toggle,areturn; Close Window#k::winclose, Areturn; Get window Class#?::wingetclass, Win_cls, Amsgbox,%win_cls%

Finally, if you want to implement multiple desktops under Windows, you can install the Virtualwin software directly.

Create the same Linux operating environment on Windows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.