Dan*_*n L 3 shell terminal command-prompt
我已经广泛定制了终端提示符的外观/感觉,以便它输出以下内容(用于开发工作):
== [~/current/path] (git_branch_name) $
==当我查看大型文本博客时,我使用来帮助识别提示行。
然而,使用几个月后,我发现很难轻松浏览终端并知道是什么。
我的想法是缩进所有输出会有所帮助。我知道我也可以改变颜色,但想同时使用这两种解决方案。
但我不知道如何缩进发送到终端的所有输出。MAN 页面对我没有帮助,我在 Google 上也找不到太多信息。
我正在尝试做什么
$ some_command_that_outputs_text
All lines of output are indented 2 spaces...
All lines of output are indented 2 spaces...
All lines of output are indented 2 spaces...
All lines of output are indented 2 spaces...
$ another_terminal_prompt
More lines are indented 2 spaces...
More lines are indented 2 spaces...
More lines are indented 2 spaces...
More lines are indented 2 spaces...
更新时间:2014-10-24
请注意,我已经为我的终端以及提示本身自定义了配色方案。我发现配色方案不足以让我个人找到我的命令,因为大部分文本本身的颜色与我的提示本身相似。
在当前情况下,bash您可以执行以下操作:
exec 1> >(sed -r 's/^(.*)/ \1/g')
Run Code Online (Sandbox Code Playgroud)
sed或者,如果您的实现不支持该标志,请使用它-r:
exec 1> >(sed 's/^/ /')
Run Code Online (Sandbox Code Playgroud)
这会将标准输出文件描述符 (stdout) 重定向到sed,从而向输出的每一行添加两个换行符。尝试一下:
$ ls -l
total 0
drwxr-xr-x 2 root root 40 Oct 22 16:35 dir
-rw-r--r-- 1 root root 0 Oct 22 16:59 file
$
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5661 次 |
| 最近记录: |