How to Add Terminal Aliases in Mac OS X Lion

One quick productivity hack is to add command line aliases to your Terminal in Mac OS X.

For example, I prefer typing c instead of clear to clear the terminal and I usually add all sorts of shortcuts for cd’ing into directories that I use often.

Here’s how to do it:

1) Navigate to your home directory:

cd ~

2) Open up .bash_profile using vi:

vi .bash_profile

3) Add an alias (press i):

alias c="clear"

4) Save the file (press Escape, type :wq, and hit Enter)

5) Restart Terminal

If you followed this example, you should now be able to just type c and Enter in Terminal to get the same affect as typing clear.

For more information, this post gives some additional examples of aliases you can add.

How to Change Your Default Terminal Prompt in Mac OS X Lion

By default, when you open up a new Terminal window in Mac OS X the command prompt displays a relatively long name:

I prefer to shorten this to a simple dollar sign ($) in order to free up space.

To change your default command line prompt, follow these instructions:

1) Navigate to your home directory:

cd ~

2) Create a file called .bash_profile

vi .bash_profile

3) Add the following line (press i)

export PS1="$ "

4) Save the file (press Escape, type :wq and hit Enter)

5) Restart Terminal

You should now see something like this:

There are other ways you can configure the command prompt (for example, showing the current time), but I prefer to keep it simple.

How to Change Your Default Screenshot Location on Mac OS X Lion

I’m just getting around to setting up my new Macbook Pro and figured I’d document my experiences in case it helps anyone else.

In order to write tutorials I need to take screenshots and by default Mac’s save screenshots to the Desktop, which I don’t like because  the Desktop tends to get cluttered very quickly.

Instead, I prefer to keep them in a separate folder reserved only for screenshots.

To change the default screenshot location, follow these instructions:

1) Create a folder called Screenshots in your Pictures folder (or wherever):

2) Open up Terminal and enter the following (one line):

defaults write com.apple.screencapture location /Users/yourlogin/Pictures/Screenshots

(Replacing yourlogin with your login name.)

3) Restart your computer for the changes to take effect

After you restart, new screenshots will be automatically saved to the Screenshots folder instead of the Desktop:

Hat tip to Macworld for the original instructions.

How to List Your WordPress Posts by Category

There’s a nifty WordPress plugin called List Category Posts that makes it dead-simple to list all of the blog posts in a specific category of your blog.

Why is this useful? If you’ve been blogging for a while you’ve likely got a lot of valuable posts buried on your blog that aren’t easily accessible to new visitors. Most bloggers include a list of categories on the side of their blog, but if you’ve got a lot of items filed under a category it can take a while to peruse them all the posts. By creating a a list of posts sorted by category, you can point new visitors so they can get familiar with your site; it acts as a site map.

Your should create a blog post that lists all of your blog categories with a list of posts below them. Then include a link to it somewhere prominently on your site so new visitors can quickly scan your old posts.

You can see the list of posts I created for this blog here. And here’s what the post itself looks like:

The name attribute refers to the category name (make sure you put categories that have multiple words in quotes), numberposts specifies how many posts you want to be displayed for that category (-1 means list everything), and date tells it to display the post date next to the link.  You can see all the options on the plugin’s Other Notes page.

And the great thing about this is that it will update automatically as you add new posts.

To add a link to your side bar, go to Appearance > Editor > Sidebar and add a link to that blog post:


Enjoy!