Hack and / - Do the Splits
Even with the high-resolution flat-screen monitors we have these days, screen real estate still can be at a premium. Of course, if you spend a lot of your time in a terminal, this is even more true. When you want to compare two files at the same time or monitor two different sessions at once, you either carefully position terminal windows or rely on tabs.
Tabs can be fine, but when I use terminals, I like to stick to the keyboard as much as possible. Plus, I don't know about anyone else, but for me, there are four main programs I run in terminals: mutt, vim, screen and irssi. Luckily for me, all of these programs support some form of split screens—the ability to divide the terminal either vertically or horizontally. Although these features aren't necessarily anything new, if you don't use them every day, it can be hard to remember how to split the screen, navigate between the sections, and then go back to a single screen. In this column, I discuss the split-screen features in my four favorite terminal applications and provide a simple guide to help us all commit them to memory.
I suppose if you want to be technical, this isn't exactly the same as the split screens in the other tools, but while you are in the mutt pager (the part that lets you view the body of an e-mail message), by default, mutt fills the entire terminal with the e-mail. If you want, however, you can tell mutt to take a specified number of lines at the top and use them to display your index. This way, you can browse through the contents of an e-mail message but still be able to keep an eye on the other headers in your index. To use ten lines for this feature, simply add the following:
Vim is my favorite text editor (I've used it for basically all of my writing), and its split-screen feature is especially useful for sysadmin work. I can't count how many times I've made a change in one configuration file or script that I've wanted to add to a second file. To enable split-screen mode for a horizontal split, type:
And, for a vertical split, type:
By default, vim shows the same file in both panes. Press Ctrl-W, and then use the regular HJKL keys (or arrow keys if you aren't a home-row junkie like me) to navigate between panes. So, if I had made a horizontal split and wanted to open a new file in the bottom pane, I would press Ctrl-W J to move the cursor to that pane, and then I would type :open filename to open the new file. When you are finished with a particular pane, make sure the cursor is in that pane, and then save and close the file in the normal fashion.
Vim isn't limited only to two panes either—simply type the :split or :vsplit command again to add a third horizontal or vertical pane, respectively. You even can split the window horizontally and then type :vsplit to split that pane further into two vertical panes.
Screen is another one of those indispensable command-line tools. If you haven't used screen before, it essentially allows you to open multiple numbered shells, and you can switch to them with Ctrl-A <number>. Then, you can detach from your screen session and connect to it later, and in the meantime, all the shells you have opened within it keep their state. One way I commonly use screen is for irssi, a command-line-based IRC client. I open irssi within screen on a server that is always up. Then, no matter where I am, I can connect to the remote server and resume my irssi session, which always stays connected.
Beyond the standard screen features, screen also supports a horizontal split screen. This can be useful if you want to monitor IRC in one window and perform other commands in the second. Also, if you use a text editor or other tools that don't support split panes on their own, you can use screen's split feature as a supplement.
To split the pane within screen, press Ctrl-A Shift-S. Then, you can press Ctrl-A Tab to move your cursor between the two panes. You will notice that the bottom pane is empty at the beginning. Once you have moved the cursor to it, you either can switch to a currently open window with Ctrl-A <number>, or you can press Ctrl-A C to create a new window in that pane. Screen also supports multiple panes. Simply press Ctrl-A Shift-S a second time to split the session into three equally sized panes. When you are ready to close a pane, press Ctrl-A Tab until it has the cursor, and then press Ctrl-A Shift-X to close that pane.
Kyle Rankin is a VP of engineering operations at Final, Inc., the author of a number of books including DevOps Troubleshooting and The Official Ubuntu Server Book, and is a columnist for Linux Journal. Follow him @kylerankin.
|Nativ Disc||Sep 23, 2016|
|Android Browser Security--What You Haven't Been Told||Sep 22, 2016|
|The Many Paths to a Solution||Sep 21, 2016|
|Synopsys' Coverity||Sep 20, 2016|
|Naztech's Roadstar 5 Car Charger||Sep 16, 2016|
|RPi-Powered pi-topCEED Makes the Case as a Low-Cost Modular Learning Desktop||Sep 15, 2016|
- Android Browser Security--What You Haven't Been Told
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Nativ Disc
- The Many Paths to a Solution
- Naztech's Roadstar 5 Car Charger
- Synopsys' Coverity
- Securing the Programmer
- RPi-Powered pi-topCEED Makes the Case as a Low-Cost Modular Learning Desktop
- Identity: Our Last Stand
- Glass Padding
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide