Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my ubuntu terminal I have always current directory shown completely. Just like this:


But in my Mac (Mac OS X 10.6.5) terminal does not show the full path and it is like this:

blabas-MacBook-Pro:classical beethoven$

Is there anyway that I change mac terminal behavior to act like linux terminal?

share|improve this question

migrated from Jan 31 '11 at 16:17

This question came from our site for professional and enthusiast programmers.

there must be a screen in preferences of Terminal App. which you can change behaviors. – fsonmezay Jan 31 '11 at 16:00
Linux terminals don't magically show the full path; it depends on your settings. Some linux distros configure things to show the full path by default, some don't. It all depends on the $PS1 variable. (See Asmus's answer.) – frabjous Jan 31 '11 at 18:37

To let bash return "user@hostname:path/to/directory$" as your prompt, add the following line to your ~/.bash_profile:

export PS1='\u@\H:\w$'


export PS1='\u@\H:\w$ '

if you like having a space between the $ and the command

to make the changes take effect immediately, run the following command in every open window (or restart Terminal):

source ~/.bash_profile

EDIT: A list of available strings can be found in the paragraph "PROMPTING" in the man page for bash (man bash):


  When executing interactively, bash displays the primary prompt PS1 when it is ready to read a command, and the secondary prompt PS2 when it needs more input to complete a command.  Bash allows these prompt strings  to  be  customized  by
   inserting a number of backslash-escaped special characters that are decoded as follows:
          \a     an ASCII bell character (07)
          \d     the date in "Weekday Month Date" format (e.g., "Tue May 26")
                 the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation.  The braces are required
          \e     an ASCII escape character (033)
          \h     the hostname up to the first `.'
          \H     the hostname
          \j     the number of jobs currently managed by the shell
          \l     the basename of the shell's terminal device name
          \n     newline
          \r     carriage return
          \s     the name of the shell, the basename of $0 (the portion following the final slash)
          \t     the current time in 24-hour HH:MM:SS format
          \T     the current time in 12-hour HH:MM:SS format
          \@     the current time in 12-hour am/pm format
          \A     the current time in 24-hour HH:MM format
          \u     the username of the current user
          \v     the version of bash (e.g., 2.00)
          \V     the release of bash, version + patch level (e.g., 2.00.0)
          \w     the current working directory, with $HOME abbreviated with a tilde
          \W     the basename of the current working directory, with $HOME abbreviated with a tilde
          \!     the history number of this command
          \#     the command number of this command
          \$     if the effective UID is 0, a #, otherwise a $
          \nnn   the character corresponding to the octal number nnn
          \\     a backslash
          \[     begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
          \]     end a sequence of non-printing characters
share|improve this answer
Or just enter that PS1 assignment in every open window. By the way, the export is unnecessary. – Dennis Williamson Jan 31 '11 at 16:37
Actually, if you don´t use export, your would be defining a shell variable, not an environment variable, so PS1 would not be passed globally to all processes. – Asmus Jan 31 '11 at 16:49
export com is working as suggested and showing full path, but once I restart the terminal it shows only present directory (not full path). How can I keep this forever. – JiteshW May 25 '15 at 7:53
would it be possible to explain what PS1, \u@\H:\w$ means? – Jas Jun 15 at 10:33
@Jas I've updated my answer accordingly, don't know why I didn't do this years ago ^^ – Asmus Jun 15 at 10:42

I am not sure about Mac, but in Ubuntu I've changed the Gnome Terminal prompt with

PS1="\a\n\n\e[31;1m\u@\h on \d at \@\n\e[33;1m\w\e[0m\n$ "
share|improve this answer
I like this one cause it puts it on it's own line. thanks for this! – espradley Jun 12 '14 at 14:37
very cool!!!!!! – Nikos Oct 29 '14 at 9:19

Inside PS1 value, "\w" represents the full path, where "\W" represents the current directory name only.

share|improve this answer

I made it to look very similar to centOS terminal on my Mac. Open bash_profile, on terminal

nano ~/.bash_profile

Add the following

# Show always fullpath on terminal
export PS1='\u@\H [\w]$ '

Restart Terminal and then it will looks like this

username@host.local [/Applications/MAMP/htdocs]$ 
share|improve this answer

You must log in to answer this question.