As a default, the terminal prompt shows something like:


the deeper you go into the filesystem, the less space is left for typing in commands. Can I change this to only show something like:


I mean, I can just type pwd to show where I am at. ;)

  • 1
    This should be a comment but I can't comment, sorry. In addition to hiding the current directory, the following PS1 value will visually seperate your bash commands nicely: export PS1="\n___" Apr 28, 2014 at 10:42
  • experimented on Oli's solutions. The color fonts work well in the terminal: export PS1='[\033[0;35m]\h[\033[0;33m] \w[\033[00m]: ' Sep 21, 2015 at 15:08

9 Answers 9

export PS1='\u@\h: '

That results in oli@bert: for my prompt.

If you really want something as minimalist as you ask for, try this:

export PS1='> '

You can attach that to the end of your ~/.bashrc file to have it persist between logins.

You can also get creative with some colours. Here's what I use on my servers:

export PS1='\[\033[0;35m\]\h\[\033[0;33m\] \w\[\033[00m\]: '

Giving (it's easier to see on a full black background):

My terminals

Glossary of acceptable characters in PS1

  • 3
    You can also have newlines (\n) as part of the prompt, so you could put all the info and the '>' on separate lines.
    – ak2
    Dec 9, 2010 at 12:15
  • 3
    what is the format used for setting up the colors?
    – Rakib
    Apr 1, 2012 at 21:16
  • 1
    @SyedRakibAlHasan Try echo -e "\e[31mHello World\e[0m" or echo -e "\033[31mHello\e[0m World" in a terminal, that should give you a clue. source
    – olfek
    Mar 29, 2019 at 16:48

Just to expand on Oli's answer (and so that I have a bookmark for those short-hand symbols):

The bash prompt (stefano@linux:~$) is only the first of a couple of prompts you might see:

  • PS1: the default prompt you see when you open a shell

    It's value is stored in an environment variable called PS1. To see its value, type

    echo $PS1

    This will give you something like

    \[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$

    To change it, you can set a new value for the variable:

    export PS1="\u > "

    This will result in a prompt like this:

    stefano > 
  • PS2: is your secondary prompt. This gets shown when a command is not finished. Type echo "asd and hit enter, the secondary prompt will let you enter more lines until you close the inverted commas.

  • PS3 is the prompt used for select(2)

  • PS4 is the prompt used for alt text stack traces (default: +)

To make the changes permanent, you append them to the end of .bash_profile (or .bashrc, see this question) in your home directory.

Here's a more or less complete list of shorthand that you can use when composing these:

  • \a     The 'bell' character
  • \A     24h Time
  • \d     Date (e.g. Tue Dec 21)
  • \e     The 'escape' character
  • \h     Hostname (up to the first ".")
  • \H     Hostname
  • \j     No. of jobs currently running (ps)
  • \l     Current tty
  • \n     Line feed
  • \t     Time (hh:mm:ss)
  • \T     Time (hh:mm:ss, 12h format)
  • \r     Carriage return
  • \s     Shell (i.e. bash, zsh, ksh..)
  • \u     Username
  • \v     Bash version
  • \V     Full Bash release string
  • \w     Current working directory
  • \W     Last part of the current working directory
  • \!     Current index in history
  • \#     Command index
  • \$     A "#" if you're root, else "$"
  • \\     Literal Backslash
  • \@     Time (12h format with am/pm)

You can of course insert any literal string, and any command:

export PS1="\u \$(pwd) > "

Where $(pwd) stands in place of "the output of" pwd.

  • If the command substitution is escaped, as in \$(pwd), it's evaluated every time the prompt is displayed, otherwise, as in $(pwd), it's only evaluated once when bash is started.

If you want your prompt to feature colours, you can use bash's colour codes to do it. The code consists of three parts:

  • The first part before the semicolon represents the text style.

    • 00=none
    • 01=bold
    • 04=underscore
    • 05=blink
    • 07=reverse
    • 08=concealed
  • The second and third part are the colour and the background color:

    • 30=black
    • 31=red
    • 32=green
    • 33=yellow
    • 34=blue
    • 35=magenta
    • 36=cyan
    • 37=white

Each part can be omitted, assuming starting on the left. i.e. "1" means bold, "1;31" means bold and red. And you would get your terminal to print in colour by escaping the instruction with \33[ and ending it with an m. 33, or 1B in hexadecimal, is the ASCII sign "ESCAPE" (a special character in the ASCII character set). Example:

"\33[1;31mHello World\33[m"

Prints "Hello World" in bright red.

  • I appended export PS1='\[\033[1;31m\]\w\[\033[00m\] \$> ' to /etc/bash.bashrc but nothing seemed to change... it works on a per session, but i cant seem to make it permanent. Nov 15, 2013 at 21:10

Another alternative is to shorten the working directory path when it gets too long: trim the terminal command prompt working directory

Create a small python script which implements the desired trimming logic.

Example: ~/short.pwd.py

import os
from commands import getoutput
from socket import gethostname
hostname = gethostname()
username = os.environ['USER']
pwd = os.getcwd()
homedir = os.path.expanduser('~')
pwd = pwd.replace(homedir, '~', 1)
if len(pwd) > 30:
    pwd = pwd[:10]+'...'+pwd[-20:] # first 10 chars+last 20 chars
print '[%s@%s:%s] ' % (username, hostname, pwd)

Now test it, from a terminal:

export PROMPT_COMMAND='PS1="$(python ~/.short.pwd.py)"'

If you are ok with the result just append the command into your ~/.bashrc

  • Exa...~/short.pwd.py , export ... ~/.short.pwd.py I think both have to be the same. Either you put an extra command in both the places or you don't do that at all. But this is an excellent answer..
    – MycrofD
    Apr 19, 2017 at 10:09

I often want to do this temporarily. Here's what I do:

$ export OLD_PS1=$PS1                    # save Long Prompt to OLD_PS1
$ export PS1="\u > "export PS1="\u $ "   # change to PS1 to Short Prompt
$ export PS1=$OLD_PS1                    # restore Long Prompt to PS1

I hope this helps someone.


for macOS users:

open ~/.bash_profile

at the end of the file add the following line and save it

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

result at home directory:

user: ~$

here u for user w for current working directory $ is to prompt to display

you can try the following styles:

export PS1='$ '

to just have $ as prompt, nothing else. just like:

  • Should have been the right answer. Works with Ubuntu as well. Nice and up to the point. Wonder why so many people paste long tutorials whereas only a one liner is needed. Oct 18, 2022 at 13:23

The thing that helped me was: export PS1='$ '

In order to have this each time you open the terminal, write the command at the end of the .bashrc which you can open by 'cd' followed by 'gedit .bashrc'.

Hope this helps. Worked out for me.


In ubuntu 20.10 I used the following steps on the default .bashrc file in my home directory

0. cd ~
1. cp .bashrc .bashrc.bkpa
2. nano .bashrc
3. ctrl+w -> PS1
4. Change the PS1 block of code to the one below (I *AM* playing safe here)

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\$ '

5. save file, exit
6. source .bashrc 

reopen terminal


In bash 4 you can use PROMT_DIRTRIM=1 in your .bashrc file to trim down your current working directory path shown on terminal.

Courtesy : How do I shorten the current directory path shown on terminal?

here is some example.

before :



  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Error404
    Oct 30, 2021 at 4:25
  • Add context to the link by replacing "link" with the title of the question Oct 30, 2021 at 4:59
  • how is it now daddy?
    – spazmantiz
    Oct 30, 2021 at 6:21

To shorten the current working directory path

  • Open bashrc file:

  • vim ~/.bashrc

    PS1='${debian_chroot:+($debian_chroot)}[\033[01;32m]\u@\h[\033[00m]:[\033[01;34m]\w[\033[00m]$ ‘

  • In the above line of the .bashrc file, change the ‘w’ to an uppercase letter like below:

    PS1='${debian_chroot:+($debian_chroot)}[\033[01;32m]\u@\h[\033[00m]:[\033[01;34m]\W[\033[00m]$ ‘

  • Save the file and open a new terminal window.

  • Not what the OP asked.
    – David
    Apr 24, 2023 at 11:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .