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 systems architect; and the author of DevOps Troubleshooting, The Official Ubuntu Server Book, Knoppix Hacks, Knoppix Pocket Reference, Linux Multimedia Hacks, and Ubuntu Hacks.
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
|Non-Linux FOSS: Seashore||May 10, 2013|
|Trying to Tame the Tablet||May 08, 2013|
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Download the Free Red Hat White Paper "Using an Open Source Framework to Catch the Bad Guy"
- Home, My Backup Data Center
- Tech Tip: Really Simple HTTP Server with Python
- Please correct the URL for Salt Stack's web site
45 min 54 sec ago
- Android is Linux -- why no better inter-operation
3 hours 1 min ago
- Connecting Android device to desktop Linux via USB
3 hours 29 min ago
- Find new cell phone and tablet pc
4 hours 27 min ago
5 hours 56 min ago
- Automatically updating Guest Additions
7 hours 5 min ago
- I like your topic on android
7 hours 51 min ago
- Reply to comment | Linux Journal
8 hours 12 min ago
- This is the easiest tutorial
14 hours 27 min ago
- Ahh, the Koolaid.
20 hours 5 min ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?