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?

stroop
  • 33
  • 5

1 Answers1

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$
Fabiano Francesconi
  • 1,769
  • 1
  • 19
  • 35
  • I'm using .bash_profile to export my PS1 (on mac) and this didn't do anything. Does that make a difference? – stroop Sep 08 '15 at 21:54
  • Try executing the command directly in your shell to see if it does something first – Fabiano Francesconi Sep 08 '15 at 21:55
  • Oh, well I missed a letter. It adds an additional new line *after* the output, though. Not before. – stroop Sep 08 '15 at 21:59
  • `trap echo debug` works, but it does add about 7 new lines before my prompt when I first launch a terminal window. – stroop Sep 08 '15 at 22:06
  • 1
    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. – rici Sep 09 '15 at 00:03