Oct 22 2010

Mac Command Line Tricks

Published by at 11:06 am under Code

Mac OS XI’ve slowly been moving over to a new MacBook Pro and trying to learn a new system. One of the things I’ve never given up from my Unix days is the command line. Even on my Windows PC, I have tcsh installed, which is my normal way of navigating through my files.

One of the “must have” hacks for my terminal window is getting the current path into the title and customizing the prompt.  With a bit of Google-fu, I was able to figure out the command sequences to do this.  Just add the code below to your

~/.bash_profile

To set the title of a Mac Terminal Window:

function settitle() { echo -ne "\033]0;$@\007"; }
function cd() { command cd "$@"; settitle `pwd -P`; }
settitle `pwd`

To set the command prompt so that it displays the current directory name with the history number of the command:

PS1="(\!):\W>"

No responses yet

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.