📜 ⬆️ ⬇️

Environment anticipating thought

desktop If hundreds of articles are devoted to effective work in cli / bash / vim, there are hardly a few articles on the organization of the working environment of a sysadmin. Most often these are screenshots of some Enlightenment with 1 transparent terminal, a clock, a calendar, 15 CPU load widgets and a naked anime woman in the background. Suitable for the movie "Hackers", not suitable for work. We need the terminal to appear before we even thought about it, do our job and disappear without a trace until the next clock cycle.

Disclaimer

It is assumed that you have been admin / devops for five years and are able to find answers in Google. My task is to ask the right questions. Implementation examples will be given for Windows. Alternatives for * nix-shaped systems are offered to readers as homework.

Authorization

image First, all authorization must be keyed. I did not see anything more clumsy than driving the host in memory each time, after which I entered my login and copy the password from the special secret file passwords.txt on the desktop. The key (or keys, if you keep good relations with employers) must be loaded into the agent. The key, of course, must be password protected. After all, he probably lies in My Documents. And they are backed up to some kind of dropbox / Wuala / ownCloud. And this one is probably connected in your favorite mobile phone with password memorization. I lost my mobile phone - go to all all the hosts where your key was and change it. Sounds like a branch of hell, doesn't it?
Implementation : install PuTTY . Generate and place your .ppk in the Start-up folder. Pageant will do the rest.

Fast access

image Secondly, the choice of the desired host should take no more than 700ms. Many people think of creating a session for all hosts in Pageant, but after all they are still looking for a tiny icon in the tray with the mouse, they select Saved Sessions, they search for a name in the huge list ... I’ll skip the obvious point that all the work should be done from the keyboard. Well, except that lazy scrolling of web pages using mouse gestures, but this is not our case. Requires access to the list of hosts by shortcut'u searchable.
')
Implementation : Launchy (freeware) + PuTTY plugin . I'm hanging on Alt + Space . In addition to an excellent search for files and commands, it allows you to search by Pageant's sessions, guessing the names by several letters. Suppose if you have a session:

you just need to enter “c2h1” to get to Client1_Host2 (in this artificial case, even just “21” will suffice). You can even enter "c1" and choose the right car from three - Launchy will remember your choice and next time will not ask questions.

Window manager

image Thirdly, the windows should be optimally located on the screen, not crawl on each other and resize when resizing neighbors (docking). I appreciate (almost without sarcasm) Windows's attempt to implement Win-Arrow tiling. But with modern resolutions of 24 ″ + monitors, two giant panels of terminals are a clear overkill. Yes, and usually two windows are not enough - you need 2-3 terminals, a browser with mana, mail or Skype - as you like.

Implementation : Plumb (for personal use). Automatically arranges windows according to the grid you set. My screen is divided into 5 parts - on the left the full third of the screen is assigned to the most active window, the rest of the space is divided 2x2 for the other background tasks (tail -f, watch -d, mtr). I don’t need to drag and drop new windows from place to place, freeing up space among other windows - the last 5 active windows on my screen.

What does this give us?

Now consider a fictional situation from real life, in which all the bonuses of this system will become clear. You read Habr; a colleague-programmer approaches you and asks: “Pasha, Client1 on the first host has already completed the very long query that I made without the slightest knowledge of the internal architecture of the base, diligently ignoring indexes and using the most poorly optimized operators?”.
You put your fingers on the keyboard and give the first chord: Alt-Space c1h1 ENTER . I bet people will not even notice what happened. You just touched the keys, and at the same second the window with Habr moved aside, and the open terminal Client1_Host1 took its place. For a person who is accustomed all his life, at best, to look for the desired tab in a long list of open sessions, it will already look like magic.

In the terminal you are doing something like “pgrep -af long_query”, you see that the process is still hanging and pressing Ctrl-D. The window closes, and Habr (previous active window) returns to its place. You do not need to collapse the terminal, thinking that you will still work with this host - you know that it is faster to open a new one than to search for the old Alt-Tab or target it in the taskbar.

After 2 minutes, a colleague returns with the same question. This time you will be faster than the station terminal. Watch your hands. Alt-Space ENTER UP ENTER Ctrl-D . What was it - Fatality? Launchy remembers your last command, you don’t even have to look at its window. They opened the terminal, called the previous command in the shell, saw a non-zero result and closed the window.

Here he comes for the third time, and in order to get rid of him, you launch “watch -d !!” in the newly opened terminal and drag the window to the corner. Habr again occupies the main part of the desktop, and watch in a small window will highlight changes in the process list when a long query to the database is completed.

This is only one part of the teaching of the Quick Hand. It consists entirely of the following sections:

1. The environment, anticipating thought;
2. Fast bash;
3. Unix-way in working with files;
4. Vi (m), strict but fair.

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


All Articles