Friday 8 October 2010

Setting up a Mac 04: Fixing the Terminal and Bash

OS X pictureBeing a command line junkie, I find the default bash shell settings on the Mac need a few tweaks. Only two files need to be changed, the bash login configuration file (.bash_profile) and the bash run control file (.bashrc). A good explanation of both can be found here.



.bash_profile

The only change here is to call the .bashrc file on the login.

. .bashrc



This will load the settings in the .bashrc file every time the login shell is executed.



.bashrc

Two things to do in this file. Colorize the ls command and change the command prompt.



alias ls='ls -G'

alias ll='ls -lG'



export PS1='\w \$ '



The -G option colorizes the results. The PS1 changes the command prompt to show only the current directory and the dollar sign. This gets rid of rather long default host name.



If you want to change the host name, go to the sharing preferences and change the Computer Name. Then you can leave the prompt like this:

export PS1='\h:\w \$ '

No comments:

Post a Comment