在每个 bash 命令的输出后添加换行符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19609770/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add newline after output of every bash command
提问by bitpshr
I'm in the process of customizing my terminal.
我正在自定义我的终端。
Currently, I have the following:
目前,我有以下几点:
What I want is a newline after the output of every command, like this:
我想要的是每个命令输出后的换行符,如下所示:
The only way I have been able to accomplish something close to this is by adding a newline at the beginningof my PS1
. This works, but it annoys the hell out of me that the first time I open up a bash prompt, there is a newline above the very first line. Is there any other way to accomplish this?
我已经能够有所建树接近这一点的唯一方法是通过在加入新行开始我的PS1
。这是有效的,但是当我第一次打开 bash 提示时,第一行上面有一个换行符,这让我很恼火。有没有其他方法可以做到这一点?
回答by Gilles Quenot
One approach using printf :
使用 printf 的一种方法:
$ printf '%s\n' * $'\n'
or better (for every commands) :
或更好(对于每个命令):
$ PROMPT_COMMAND="echo"
$ ls
From man bash
:
来自man bash
:
PROMPT_COMMAND
If set, the value is executed as a command prior to issuing
each primary prompt.