有没有办法让我刚刚输入的命令在输入后回显到屏幕上?
前任:
$ echo hello
+ echo hello
hello
Run Code Online (Sandbox Code Playgroud)
我知道可以这样做bash -x
,但我在 zsh 手册中找不到等效的内容。
-x
(或)选项也-o xtrace
适用zsh
。它来自 70 年代末的 Bourne shell,并受到所有类似 Bourne shell 的支持。从man zshoptions
/ info zsh xtrace
:
Run Code Online (Sandbox Code Playgroud)XTRACE (-x, ksh: -x) Print commands and their arguments as they are executed. The output is preceded by the value of $PS4, formatted as described in the section EXPANSION OF PROMPT SEQUENCES in zshmisc(1).
例子:
XTRACE (-x, ksh: -x)
Print commands and their arguments as they are executed. The
output is preceded by the value of $PS4, formatted as described
in the section EXPANSION OF PROMPT SEQUENCES in zshmisc(1).
Run Code Online (Sandbox Code Playgroud)
和一个运行示例:
#!/bin/zsh -x
echo hello
Run Code Online (Sandbox Code Playgroud)
与bash
/中一样ksh
,可以使用set -x
或启用它set -o xtrace
,然后使用set +x
或禁用它set +o xtrace
。还可以使用functions -t myfunction
.
请注意,在交互式 shell 中,如果您启用了许多奇特的插件或高级完成功能,那么您还将看到与可能影响您的交互式 shell 体验的那些执行相对应的跟踪。
归档时间: |
|
查看次数: |
1097 次 |
最近记录: |