bash prompts

Tony Arnold tony.arnold at
Sun Jan 21 17:46:04 UTC 2007


Michael V. De Palatis wrote:
> On Sun, Jan 21, 2007 at 12:31:38PM -0500, Seth Hasani wrote:
>> On 1/18/07, Michael V. De Palatis <mvd at> wrote:
>>> I've decided that I should increase the readability of bash since I
>>> spend so much time on it. At this point, I have set the prompt like
>>> so:
>>> user at host:/current/working/directory
>>> [nn]$
>>> where "nn" is the current command number (unnecessary, but can
>>> occasionally be useful). Additionally, there is an extra newline
>>> between the last command output and the "user at ...". What I want to
>>> add, however, is yet another newline between my command and the
>>> command's output, e.g.,
>>> user at host:/current/working/directory
>>> [nn]$ run_some_command
>>> First line of output
>>> Second line of output
>>> I have so far not been able to find out how to do this. Any ideas?
>> How about adding newlines at the beginning of your prompt:
>>     export PS1="\n\n\u@\h: \w\n[\#]\$ "
> This is essentially what I already have. What I want is an *extra*
> newline between the command and the command's output.

I think you will have to write a script to do this as I don't think
there is anyway to do it via the bash prompt settings.

The script would have to read the command from the keyboard and then
echo the newline you want before it executes the command. You probably
only want to do this if stdin is a tty!

You may have to take care of exit status codes returned from the command
and may have to handle control-C and also not exit on control-D etc.

Just my thoughts.

Tony Arnold, IT Security Coordinator, University of Manchester,
IT Services Division, Kilburn Building, Oxford Road, Manchester M13 9PL.
T: +44 (0)161 275 6093, F: +44 (0)870 136 1004, M: +44 (0)773 330 0039
E: tony.arnold at, H:

More information about the ubuntu-users mailing list