Everybody using the Macs command line interface frequently can customize it with some very simple steps.
Customize Prompt
To customize the default bash prompt you have to edit the environment variable “PS1″. The standard prompt of Mac OS X looks like the following:
hermes:~ eddie$
You can use multiple further options on this prompt e.g. to show the time, command number, coloring parts of the prompt. If you want to create a prompt like
15:43:38 eddie@hermes: ~ (1) $
you have to insert the following line into ~/.bash_profile:
export PS1="\[\e[0;36m\]\t \[\e[0;32m\]\u@\h: \[\e[0m\]\w (\#) $ "
(Insert the above command in one line!)
You can get further infromation from the bash man page. A detailed tutorial to customize the prompt is also available. You can find an overview about the different color codes at the Bash Prompt How-To. Also you should read the complete How-To to tame bash.
colored output for “ls”
To color specific files (symbolic links, directories) you can call “ls” with the option “-G”:
hermes:~ eddie$ ls -G
You can define this command as an alias inserting the following into ~/.bash_profile to activate the colored output by default:
alias ls="ls -G"
Alternatively you can set the environment variable “CLICOLOR”:
export CLICOLOR="yes"
Leave a Reply