The way to configure my LIUNX development environment

Source: Internet
Author: User

I believe there are a lot of people like me, although to do pure Linux development, but do not exclude windows, and like Windows under the use of a variety of useful tools to make Linux programming easier. In fact, every system has his support, Windows has countless easy-to-use Windows programs, but Windows command-line tools are basically degraded to the same situation as human fingernails. Linux has just the idea of having an omnipotent terminal and countless commands, but his graphical interface and user experience really have a long way to go. As for Apple's Mac, we can say that he has a graphic interface experience that is even far away (in some people's eyes) windows, and has a terminal tool that works just as well as Linux. The only pity it is relatively closed and a lot of things self-contained. For me, the status of these systems is equal, but the difference between the Black Cat white cat. Therefore, in the Linux development work I chose is the multi-system combination route, the host system uses the more convenient Win7, uses the virtual machine to build the Linux development environment.

In fact, there are many other reasons for this kind of collocation, for example, although in many people's eyes the virtual machine does not have a pure Linux system running fast and pure, about speed, in fact, has become the past time, if you have a performance equivalent or beyond the third with desktop i3 performance of the CPU, An up-to-date VMware or VirtualBox and a popular and newer Linux distribution, I think you will find that the loss of virtual machines in new performance will hardly bring any trouble to your work. The best way to improve efficiency is to get a i7-level CPU without using a virtual machine. The question of the purity of the system is really just a matter of whether you would like to take the time to solve it. If you are using a virtual machine, you have to face nothing more than the virtual machine network and host how to topology, the virtual machine's file and host how to share, the virtual machine's graphical interface how to enhance, USB device how to use the virtual machine and other issues, in fact, these problems, As long as you use a popular Linux distribution as a development environment (especially one that answers a lot of questions like Ubuntu), it will not be a problem. In particular, the network card sharing and topology, I initially used for a year or two have always felt that the virtual machine network is prone to problems, some network problems I always first suspect that the network environment caused by the virtual machine, but then I found that I was wrong, practice proved that You should hardly suspect any of the features of the virtual machine virtual network card. The cause of the problem is basically that you are not configured correctly.

OK, about the merits of the virtual machine is not the topic of today's discussion, in view of today's content and directly related to the virtual machine, the front will inevitably spend a bit of text in the rehabilitation for the virtual machine, the main hope is to use a pure system of people see this article do not in the heart said "Linux development also use virtual machine, really good The things that human beings create are always progressing, and virtual machines are no exception.

  When using a virtual machine to develop a problem, there are two main scenarios to choose from, the first option is to use the virtual machine login graphical interface, direct full-screen or window mode in the virtual machine in the graphics community to work. The benefit of this is that there is no problem with clipboard sharing, because any virtual machine software has a function to share the clipboard between the host and the client, if you want to open it in the configuration. But if you use the virtual machine's graphical interface to do the development, you will face a switch between Win7 and Ubuntu control, which mainly shows who will take over our only mouse and keyboard, usually the best solution is to set a global switching hotkey to allow control to switch between the two systems , VMware uses the Ctrl+alt key combination to switch by default, and VirtualBox uses the right CTRL to switch by default. Regardless of the use of the virtual software, frequent use of this switch hotkey is not able to avoid. Of course, the students of the mouse flow can be used in the window mode to use the virtual machine and use the mouse to quickly switch between the two system keys. So in fact this problem for the mouse party is not too big problem, unfortunately, I am a keyboard party. The second problem that keyboard parties may encounter with virtual machine graphical interfaces is the ALT key response problem in the virtual machine, the specific manifestation of which is that if your vim has a number of ALT combination shortcuts, you will find that in the Linux terminal vim operation of these shortcuts, they often have a large probability to identify the ESC and key combination the second key for two key inputs. The problem with this issue is that the keyboard input is handled by both the virtual machine and the Gnome-termal terminal, regardless of whether it is with VMware or VirtualBox, and the keyboard input always comes first to Windows and then the virtual machine software is delivered to the virtual machine. This scenario and pure Linux host directly take over the keyboard hardware will always be written in, and this access to the Gnome-terminal terminal on the keyboard flow processing of the hand, so gnome-terminal have a large chance to the ALT key identified as the ESC key, As for why it is wrong to identify the ESC key instead of the other key, it is important to understand the historical origins of the system-to-ALT key processing. If you are interested, Baidu Google will understand. If you're using a Linux distribution that's not Ubuntu, but the KDE version of openSUSE or Linux_mint, or if you switch the Ubuntu GUI to KDE, you won't get this problem. Because the KDE system's default terminal Konsole does not have this bug in the virtual machine to handle the keyboard stream (at least I think this is a bug). So the simplest way to solve this problem is to abandon the use of gnome-terminal and use konsole or simply abandon Ubuntu. It's a pity.This is also a disadvantage, to abandon Ubuntu and instead of using KDE desktop in the use of the habit will have a relatively big change, KDE desktop flexibility than not gnome much more, you need to spend some time to adapt to and sanding the KDE desktop, In fact, KDE4 support for virtual machines is much better than gnome. In fact, the use of KDE desktop is a positive advantage, but there is a more serious negative problem is that the Konsole terminal to the font rendering really no gnome good, Ubuntu gonme-termail Terminal font rendering sharp and clear, And Konsole's font is always a bit more blurred. This ambiguity is very uncomfortable for Linux code farmers who use the terminal all the way, at least for me. Alas, God always surprises you and does not forget to slap you in the face.

In addition to the control between the host and the virtual machine keyboard switching inconvenience and the use of terminals in the Linux graphical interface always disappointments two problems, there is an important problem that I recently gave up directly in the virtual machine using the graphical interface. That's my favorite yahei_mono. Mixed fonts in Linux endpoints are completely and not a level below windows, although I have found a modified version of the Yahei_mono for Linux fonts, but this font performance is still not as pleasant as under Windows.

As a result, I finally gave up using the Linux GUI to operate the virtual machine, instead of managing my Linux system by using SSH to log in to the virtual machine under Windows. This directly solves the three issues mentioned above: Because of the use of Windows native SSH software to log on to Linux, the two system key switching problem is not, because all under the control of Windows. The problem of ALT key combination in Vim does not appear in the way SSH telnet. Finally, I can happily use native Yahei_mono fonts that were synthesized for windows in Win7.

As mentioned above, God always surprises you at the same time do not forget to give you a slap, SSH landing Way has its advantages and soon I found this use shortcomings. The first tool software I chose to ssh into the virtual machine was the famous putty. The advantages of putty are small and efficient compatibility. But soon it exposed his first shortcoming, which does not support the terminal background transparency. As I got used to the slightly transparent background that I had in the gnome terminal that was comfortable for me, I felt very depressed by the putty background. It's a big problem to be depressed as long as people are depressed. Fortunately, there is always the need for action, my demand seems to be the only desire in the world, I soon found the support of the transparent effect of the Putty enhanced software: Pietty. This software can not only perfect the background transparent, but also more refreshing is that he can implement the window frame and the menu bar completely hidden, under Windows with a close button can not find a translucent window to operate another Linux system, the light is very tall. What the? You asked me how to close the button without closing it? Shortcut keys Ah!!! This is a great way to recommend the artifact (AutoHotkey) that sets the shortcut key under Windows and the handy sub-item that it implements vimdesktop! Finally Pietty also has a cool function, all configurations can be set to store in the software in the same directory of the Pitetty.ini, which will simultaneously achieve the configuration of backup, software greening and portability.

Using SSH login to control Linux There are a lot of problems that can be solved: the first is that you can only operate Linux on any graphical interface through the terminal is not supported, fortunately, Linux and development-related 90% of the work can be done in the terminal (often 90% of the work is only done in the terminal). Other requirements, such as browsers, the use of debugging tools, and much more can be done directly under Windows (the graphics software used under Windows is often more useful than Linux). Finally, there are few things that must be done in the Linux GUI to switch to the virtual machine's graphical interface. The second one solves the problem by default, an SSH connection can only produce one terminal. This is often not enough for engineers who use the terminal to develop at all. There are two ways to solve him, the first is the simplest, a few more pietty to generate multiple SSH connections. The disadvantage is that you have to open a few more pietty before you work every day. The second one is a little bit higher: Use the Terminal multi-window management software to manage multiple shell processes in one terminal. This terminal multi-window management software is the originator of the screen command, is interested in more Baidu Google. However, screen is too old, many features are not perfect, want to play a good terminal in the multi-shell switch, or to ask a rising star tumx. It takes a bit of effort to configure and use the TUMX. Here is not much to say, is interested in more Baidu Google it. The order posted here I spent some time collecting the. tmux.conf configuration file and the. BASHRC and Tmux related configurations: The configuration in BASHRC implements the ability to automatically create 4 shell windows after SSH login.

. tmux.conf Collection of configurations:

# Tmux2.2There is a problem in Ubuntu where the window split line is broken when the page is paged in Vim #"vim:set Ft=screen: Show mappings in Vi-cope mode Tmux list-keys-t vi-copySETW-g UTF8 on# escape- Time=0 increased the ESC key's response speed in Vim, very important configuration set-G escape- Time 0# Index starting from 1 set-G Base-index1Set-G Pane-base-index1# can automatically adjust the window Indexset-G renumber-the title of the Windows on# remote terminal joins the currently running program name # SETW-G automatic-Rename offset-G set-titles Onset-G set-titles-string '#W-tmux'# Historical buffer size and terminal type setting set-G History-limit81920# Set-G default-terminal"Screen-256color"# Tmux's copy mode uses VI mode and some useful mappings setw-G Mode-keysVIBind-TVI-copy v begin-Selectionbind-TVI-copy/search-Backwardbind-TVI-copy? search-Forwardbind-TVI-copy Space page-Upbind-TVI-copy m page-Downbind-TVI-copy y Copy-pipe'xclip-in-selection Clipboard'Bind-SPLITW-vbind \ SPLITW-hbind \ SELECTP-rbind q killpbind zKill-session# pane split bar, status bar, message display, copy mode and other display style settings (subject) #status bar using UTF-8Set-G status-UTF8 onset-option-g status-position top# modes# SETW-G mode-FG colour34# SETW-G mode-BG colour233# Messagesset-G message-FG Colour221set-G message-BG colour234# Panesset-G pane-border-BG Colour234set-G pane-border-FG Colour234set-G pane-active-border-BG Colour234set-G pane-active-border-FG colour234# Statusbarset-G status-FG Colour253set-G status-BG Colour234set-G Status-left""Set-G status-right"#[bg=colour237]%h:%m%a%m-%d[#S]"SETW-G window-status-FG COLOUR232SETW-G window-status-BG COLOUR251SETW-G window-status-current-FG COLOUR232SETW-G window-status-current-BG COLOUR163SETW-G Window-status-format"#I: #W"SETW-G Window-status-current-format"#I: #W"# Enable the mouse mode to Tmux # forTmux version >2.0# Set-G Mouse on# forTmux Version <2.0# SETW-G mode-Mouse on# setw-G mouse-resize-pane on# SETW-G mouse-Select-pane on# SETW-G mouse-Select-window on# bind PageUp copy-mode-e# bind PageDown copy-mode-e# Set-window-option-g exit-copy-past-Bottom on# Open window event hint # SETW-G monitor-Activity on# Set-G visual-activity on

The. BASHRC implements SSH Login auto-Login Tmux and creates a configuration of 4 shell windows:

#tmux AutoLogin, mast add it at Lastof BASHRC# The default value for display is also:0, but this environment variable is not set by default at SSH login # here it is shown to set it to:0can be implemented locally with SSH login local virtual machine after the X Clipboard and windows# connectivity, but this setting in remote login is not valid, Telnet to achieve X-cut version and Windows sharing, # must pass Xmanager and other complete xserver services. Export DISPLAY=:0if["$SSH _connection"!="'-A"$TERM"!='Linux']; ThenExport Term='Xterm-256color'    if[! $TMUX]; ThenTmux has-T0 1>/dev/NULL 2>/dev/NULL        if[ $? =0]; ThenTmux-2aElseTmux New-d tmux neww tmux neww tmux neww tmux selectw-T2Tmux-2afi    fifi

Attention:

* Only 4 shells will be expanded when SSH is logged in. Oh, the launch terminal directly in the virtual machine will not call Tmux

*. tmux.conf is configured with window tabs at the top of the terminal, so that more in line with the current popular multi-label page display effect

* Tmux shortcut key itself is relatively lame, but we can use AutoHotkey to achieve a more convenient shortcut map to the tmux commonly used shortcut keys up, the most useful mapping is naturally the multi-window switch between the shortcut keys

The third problem with Pietty is that Pietty does not support the display of some of the special characters in Utf-8 encoding, which in fact has little effect in daily work, that is, some of the most uncommon characters cannot be displayed. But the problem is most obvious to me. There are two places: one is the Tmux window splitter line does not display properly. The other is that I use Vim's Ydt.vim plugin to query the English word interpretation when the pronunciation of some of the phonetic characters can not be displayed. In fact, this problem is related to the font, if you use a full-character font, Pietty can also display these special characters. Unfortunately I yahei_mono not contain these special characters.

Special characters can not be displayed is a small regret to use pietty, there is no solution, the answer is some, the method is to use Xshell instead of Pietty. First look at some features of Xshell: Xshell is a part of the Xmanager Suite, is a dedicated telnet, SSH, serial and other login tools. By personal practice, Xshell owns so Pietty features, including background transparency adjustment, Xmanager suite greening, configuration file backup, etc. The only feature that Pietty has but Xshell not has is the window frame hidden. Xshell has a unique feature that I personally feel is the ability to use his built-in fonts to display special characters that many fonts cannot display, including the Linux line drow extended characters and phonetic transcription. To enable the display of these special fonts, simply tick the following two configuration choices (use the built-in font to draw line characters, use the built-in fonts to support Powerline):

The last topic in this article is a fairly practical and important feature implementation: How to use the SSH terminal to implement Linux cut and Windows cut between the sharing!!!

  I believe that anyone who has ever used SSH to log on to a Linux host (including a local virtual machine or remote server host) and has used VIM to do a task will encounter this problem. You will soon find that the content you copy in Windows is a bit inconvenient to paste into Linux or to copy some content from the vim of Linux to Windows. Why is that inconvenient? Because, we can still reluctantly achieve this function, the implementation of the method is to use the mouse in Xshell (or pietty) to operate, the content of Windows copy in Xshell with the mouse paste can be pasted to Linux, Or you can copy to the Windows clipboard by selecting a paragraph with the mouse in the current Xshell display. But this way is not a good way, xshell of the principle of the mouse paste function is Xshell to help you to the Windows Clipboard content by way of analog keyboard input to the Xshell of the remote machine shell. This paste is not a problem in pasting the content into the shell command line, but there are some problems if you want to paste the content into vim. You will soon find that the pasted content is sent to vim in one character at the time of pasting, as if you typed the content with the keyboard. Just paste the automatic input is much faster than you manually input. Vim in the terminal mode itself has a disadvantage, this disadvantage no matter how you log in to the terminal, as long as the use of vim in the terminal will exist. Vim does not differentiate between what is pasted from the terminal and what the keyboard enters. This will cause your pasting process to be treated as a keyboard input in Vim. This is why vim to set a set paste Operation command Reason (: Set paste and so inform the vim behind the action is paste, please do not do extra processing). Obviously, if you paste the content does not contain the special shortcut map you set, or the content is relatively short time is not a problem. But if you paste the content is very long, the egg hurts, the first out of the paste process is slow, followed by too much content is difficult to ensure that vim will automatically process the character stream. Of course, you can avoid the problem of the pasteoggle of Vim by setting the set Pastetoggle after pasting before pasting. You can even set the setting Pastetoggle to a shortcut and then use AutoHotkey to automatically send this shortcut before and after the paste to automatically paste the button. But this is still a way to feel a bit of egg ache. Well, the process of pasting is painful, but at least it can be solved, from Linux replication to Windows can be solved by not having an egg ache.The problem. The auxiliary principle of Xshell (including Pietty) is to extract the content from the terminal window output directly to the Windows clipboard, which means that you can only copy the text that is displayed in the current window interface, all the content that is not displayed, and you cannot copy it at once. For example, if you want to copy all the output of a shell command, which takes up 5 pages, then you will have to flip a page to copy it five times in a row, and you have to worry about whether the tipping point is overlapping, and copying in vim. This is a problem of how the egg hurts Ah!!!

The problem has been very clear, there is no way to solve it, the answer is some, and very clever, clever to my realization of the time all feel baffled!

The solution is to share the Windows system Clipboard and the Linux system Clipboard, which is a two-way approach to the implementation of the Clipboard share:

1. Using the Xserver service provided by Xmanger and the automatic selection of clipboard sharing to achieve, this way of implementation is the principle of the Linux System X Window architecture itself on the implementation of the Clipboard and graphical interface of the remote interaction, about the X window architecture, interested please Baidu Google. Xshell's Xserver provides a way to automatically synchronize local Windows clipboard and remote xclient Clipboard. Because this approach requires the Linux x architecture to participate, it is necessary to configure and turn on the remote interface of the X window of Linux. Fortunately, the default configuration of Ubuntu has already turned on these features. So if you use Ubuntu, you don't have to configure it. Xshell This is a natural way to do some configuration to achieve the Clipboard sharing and complete Xserver services. First of all, you need to start the Xmanager service. Next open the Xmanager of the Clipboard sharing function, this function is not the general depth, I also spend a good long time to find (for Xmanger why designed to say no language), the following is a specific configuration record:

Double-click Xstart to start the Xstrat configuration:

Click Cancel to close the popup New Session window and click on "Advanced ..."

Click "Configure (c) ..."

Click the Advanced tab

See the "Auto copy and paste" configuration? Configure it as shown on this page to turn on the Xmanger Windows and Linux Clipboard Auto-sync feature!!!

Here, you finally opened the Xshell of the Clipboard sharing function, from the SSH terminal command line, you can continue to use the Widnows ctrl-v or Xshell right-click Paste function to paste the content, in vim as long as the use of shortcut keys "+y You can magically paste the Windows clipboard content into vim. Of course, this type of paste does not have any side effects, and vim will process very quickly and accurately. If you think "+y is too much trouble, it doesn't matter," VIMRC. Map a cool shortcut key. As for the copy that is more cool, vim you can think how to copy, as long as you remember the content of auxiliary to the "+" cut version can be automatically passed to the Windows clipboard, if you want to copy the contents of the terminal command line, a screen within the direct mouse selection, oh yes, the last need to remind, Vim defaults to No "+" number of the Clipboard, because the Clipboard in Vim represents the X window of the Clipboard, and Vim that the X Window Clipboard is part of the graphical interface, so vim is not integrated in the terminal version, if you want to use the vim "+" number cut version, use sudo apt-get installs gvim to install the Gvim under Linux.

This method is a method that allows the system to cut sharing functionality regardless of whether the local SSH is logged on to the virtual machine or the remote SSH login to the Linux server, and the second method is only applicable to locally logged on virtual machines, so this approach is important. In fact, the use of this method has a small note (at least the latest xmanger5 still exist this bug), that is, after Win7 launched Xmanager after the use of Xshell SSH login Linux after each turn off vim, The Win7 Xmanager will crash and restart once, and this crash restart process will not affect the end use but will cause the Xmanager icon in the Win7 taskbar to increase as follows:

You only disappear when you point the mouse to these extra icons, which is caused by the fact that vim crashes every time the Xmanager exits, and the cause of the crash appears to be that Xmangager provides Xserver and Linux xclient without a complete connection. Then I found a way to solve the problem indirectly. That is, after using SSH to connect to the Linux system, start a graphics program through the terminal and close it (I usually start and close the Gvim after logging in to show a full connection between Xserver and Xclient, and after you start Gvim you will see X Window architecture The most awesome ability: Gvim graphical interface directly below the Winddows appeared! )。

2. This is the way I found in an accidental configuration, it is estimated that the whole network first, this way configuration is simple, do not need to start xmanager, do not need to configure Xstart, no Xmanger to close the vim crash bug, You don't even need to download the installation configuration complete Xmanger suite, but only need to be a xshell to realize the Clipboard sharing ability between virtual machines!!!

OK, here is the time to publish the method configuration process, in fact, if you seriously read this smelly and long personal note-taking article, you can find the answer in the place before the article, yes, in the. BASHRC about Tmux in the configuration:

# Display Default value is also:0, but when SSH login this environment variable is not set by default # here is shown to set it to:0  Can be implemented locally with SSH login local virtual machine after the X Clipboard and windows# connectivity, but this setting in remote login is not valid, Telnet to achieve X-cut version and Windows sharing, # must pass Xmanager and other complete xserver services. Export DISPLAY=:0

See no, just a sentence configuration: Exprot display=:0

I don't remember how I daoteng out this configuration and found that he can implement the function of the system Clipboard sharing between the virtual machine and the Win7, and I still do not want to understand the principle that this configuration can work. But the facts are in front of them: it work!

As long as you add this configuration to the. BASHRC (I'm only successful in Ubuntu and don't guarantee that other Linux systems will do the same), you'll have a Xshell or pietty!!! that can share the system Clipboard directly between the Win7 host and the Ubuntu virtual machine.

Finally, show a variety of configuration completed after the implementation of the Xshell bar (the map includes some key configuration: Xshell background transparent, SSH login automatically login Tmux and create 4 terminal windows, Terminal window tab list at the top display, Xshell realize the system clipboard sharing, Xshell Normal display window split line and sound effects, vim presence "+" number of the Clipboard):

The way to configure my LIUNX development environment

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.