PPC4YOU.COM Mobile News.

PPC4YOU.COM Mobile News.

Latest collection of news from a number of reliable sources.

Terminal 101: 5 Time-saving Tips and Tricks

May 20 2013 6:38PM EST | Source: MacLife.com

Every Monday, we'll show you how to do something new and simple with Apple's built-in command line application. You don't need any fancy software, or a knowledge of coding to do any of these. All you need is a keyboard to type 'em out!

Whether you’re leisurely using the command line or are a Terminal wizard, saving time is always a plus. From entering a long file path by hand to viewing your command line history, there’s a command for anyone that can save time. Keep reading, and we’ll walk you through five tips that can save you a few key presses and a little energy.

1. Entering File Paths Easily

Typing out a long file path (especially when the file isn’t in your current working directory) can truly be a pain. Let’s take the hassle and typing out the equation with this simple trick for easily entering file paths into the Terminal in OS X.



When you're ready to enter your file path, simply drag-and-drop the file from the Finder into the Terminal window. When you let go, the file path, file name, and extension will automatically be “typed” into the command line for you in the blink of an eye. How easy is that?

2. Tab-completion

Tab-completion has to be one of the best things ever invented in command-line history. If you’ve been entering commands (or file paths) manually, then you will especially love this feature. Just like web searches autocomplete in your web browser, you can also autocomplete the commands and file paths in the command line.

For example, try typing the following while in the Terminal application:

cd ~/Do

Once you have that typed, press the Tab key on your keyboard. You will have “cd ~/Documents” tab-completed for you. You just need to enter the first few characters of the next part of the file path, then tab to complete. You can continually do this until you have the entire file path (or command name) automatically completed for you.

3. sudo!!

Forgot to include “sudo” in front of your typed command to indicate that you needed administrator privileges? No problem! Simply type the following command on a new line, followed by enter:

sudo !!

After typing this command, the previously entered command, prefixed by “sudo” will be automatically typed into the command line, allow you to press enter, then enter your administrator password to run the command with administrator privileges.

4. Abort a Command

Started a command, but decided that you don’t want to run it after all? No problem! Simply press Control + C to abort the command and stop it dead in its tracks. Use this only after you’ve pressed enter after a command, but note that it won’t magically “undo” unwanted commands after they’ve run -- it can only stop a running command.

5. See Your History

Forgot the command you just typed in, or want to view all of the commands that have recently been run in the command line? Just enter the following command:

history 

All of your recent commands will be printed, one per line, to the command line for your viewing pleasure. You can copy and paste from this list back into the command line to re-run a specific command.

Cory Bohon is a freelance technology writer, indie Mac and iOS developer, and amateur photographer. Follow this article's author on Twitter.


ppc4you.com is an Upfront Merchant on TheFind. Click for info. eTrust Pro Certified
Copyright © 2002-2013. ppc4you.com. All rights reserved.

Company and products names mentioned on this site are registered trademarks of their respective companies.