Take the 2-minute tour ×
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.

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

2 Answers 2

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.