3

I have my prompt set to add a new line after any preceding output, but I would like to add a new line before the output as well (after commands), effectively surrounding my prompt with empty lines for readability.

Currently I have this:

{end of previous output}

[~/Documents/scripts]
>>> stroop: echo sample output
sample output

This is what I would like to accomplish:

{end of previous output}

[~/Documents/scripts]
>>> stroop: echo sample output

sample output

Is there a way to do this by modifying PS1 or otherwise?

0

1 Answer 1

2

What about adding PROMPT_COMMAND=echo to your .bashrc? This will execute "echo" after each command.

Or you can use something like trap echo DEBUG to intercept the execution and strike that echo before each command.

This works for me:

bash-3.2$ cat .bashrc

trap echo DEBUG
bash-3.2$ cd foo/

bash-3.2$ ls

foo
bash-3.2$
Sign up to request clarification or add additional context in comments.

5 Comments

I'm using .bash_profile to export my PS1 (on mac) and this didn't do anything. Does that make a difference?
Try executing the command directly in your shell to see if it does something first
Oh, well I missed a letter. It adds an additional new line after the output, though. Not before.
trap echo debug works, but it does add about 7 new lines before my prompt when I first launch a terminal window.
The DEBUG trap runs before every "simple command", so if your command is a pipe (grep pat file | wc), you'll get a blank line for each pipe component.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.