如何在输出之前在bash命令之后添加新行 [英] How to add new line after bash command before output

查看:89
本文介绍了如何在输出之前在bash命令之后添加新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将提示符设置为在任何先前的输出之后添加新行,但我也想在输出的之前(在命令之后)添加新行,有效地将我的提示符周围留空便于阅读的行.

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.

目前我有这个:

{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

是否可以通过修改PS1或其他方式来做到这一点?

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

推荐答案

如何将PROMPT_COMMAND=echo添加到您的.bashrc中呢?每个命令后都会执行"echo".

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

或者您可以使用trap echo DEBUG之类的东西来拦截执行并在每个命令之前执行回显.

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

这对我有用:

bash-3.2$ cat .bashrc

trap echo DEBUG
bash-3.2$ cd foo/

bash-3.2$ ls

foo
bash-3.2$

这篇关于如何在输出之前在bash命令之后添加新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆