Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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

How can I configure my bash prompt to have a newline before it?

Instead of:

Output1
Output2
kshitiz@ksh$

It should have:

Output1
Output2

kshitiz@ksh$
share|improve this question
    
You should accept one of the answers below. – Dave Kennedy Sep 13 '15 at 15:53
up vote 6 down vote accepted
cd $HOME
more >> .bashrc << 'EOT'
PS1='\n$USER:$PWD>' ; export PS1
EOT

This will do it permanently for all your future terminal and console sessions.

To refresh your current sessions with this setting :

. ~/.bashrc
share|improve this answer

Find where ever the prompt is defined on your system, typically I grep for PS1 in /etc/bashrc, /etc/profile.d/* or $HOME/.bash*.

Then add a \n to the beginning of that definition.

So for example on my Fedora 19 system:

[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "

So I'd change this line to this:

[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="\n[\u@\h \W]\\$ "

Alternatively if you don't know where it's being defined you can still change it as you'd like using this trick. In your $HOME/.bashrc file simply add this line to the bottom of the file:

export PS1="\n$PS1"

Example

$ export PS1="\n$PS1"

$ ls
ve2_sq021_sc001_v09.0101.jpg  ve2_sq021_sc001_v09.0103.jpg
ve2_sq021_sc001_v09.0102.jpg  ve2_sq021_sc001_v09.0104.jpg

$ ls
ve2_sq021_sc001_v09.0101.jpg  ve2_sq021_sc001_v09.0103.jpg
ve2_sq021_sc001_v09.0102.jpg  ve2_sq021_sc001_v09.0104.jpg

$ 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.