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.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
|Fancy Tricks for Changing Numeric Base||May 29, 2016|
|Working with Command Arguments||May 28, 2016|
|Secure Desktops with Qubes: Installation||May 28, 2016|
|CentOS 6.8 Released||May 27, 2016|
|Secure Desktops with Qubes: Introduction||May 27, 2016|
|Chris Birchall's Re-Engineering Legacy Software (Manning Publications)||May 26, 2016|
- Tips for Optimizing Linux Memory Usage
- Secure Desktops with Qubes: Introduction
- Working with Command Arguments
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Secure Desktops with Qubes: Installation
- Fancy Tricks for Changing Numeric Base
- CentOS 6.8 Released
- Linux Mint 18
- The Italian Army Switches to LibreOffice
- Petros Koutoupis' RapidDisk
Until recently, IBM’s Power Platform was looked upon as being the system that hosted IBM’s flavor of UNIX and proprietary operating system called IBM i. These servers often are found in medium-size businesses running ERP, CRM and financials for on-premise customers. By enabling the Power platform to run the Linux OS, IBM now has positioned Power to be the platform of choice for those already running Linux that are facing scalability issues, especially customers looking at analytics, big data or cloud computing.
￼Running Linux on IBM’s Power hardware offers some obvious benefits, including improved processing speed and memory bandwidth, inherent security, and simpler deployment and management. But if you look beyond the impressive architecture, you’ll also find an open ecosystem that has given rise to a strong, innovative community, as well as an inventory of system and network management applications that really help leverage the benefits offered by running Linux on Power.Get the Guide