The Mac prompt is defined by the ‘PS1′ environment variable which can be defined in the ‘.bash_profile’ hidden file. To customize your Mac Terminal Shell Prompt in OS X Yosemite, follow the below steps.
1. Open a terminal window
2. With you favorite editor open the hidden file ‘.bash_profile’ in your home directory. I’ll use ‘vi’ so will type “vi .bash_profile”
3. Add the following line after the last line: export PS1=”"
Now, between the quotation marks, you can insert your custom terminal prompt verbiage. You can also use the following escape characters representing special values:
\d – date
\t – time
\h – hostname
\# – command number
\u – username
\W – current directory (e.g.: Desktop)
\w – current directory path (e.g.: /Users/Admin/Desktop)
Once you are done making the changes, save the file. If using ‘vi’, the command to save is ['esc' + ':' + 'wq' + 'enter'].
Below is an example of the original prompt on my MacBook Pro running OS X Yosemite.
Below is a snapshot of my edited ‘.bash_profile’ file.
Once I start a new shell, you can see from the below my shell prompt has changed as expected.
Tags: .bash_profile, Apple Mac OS X Yosemite, Apple MacBook Pro, Apple OS X Yosemite, BASH, BASH Shell, change Mac prompt, Change Mac shell prompt, change shell prompt, change Yosemite prompt, change Yosemite shell prompt, custom Mac shell, custom Mac shell prompt, custom terminal prompt, Customize Mac terminal shell prompt in OS X Yosemite, customize the Mac terminal shell prompt in OS X Yosemite, export PS1, MAC, Mac OS, Mac OS 10.10, Mac OS X, Mac OS X 10.10, Mac OS X Yosemite, MacBook Pro, OS X, OS X Yosemite, PS1, shell prompt, terminal prompt, terminal window, vi, vi editor, Yosemite