终端,退出状态右对齐

问题描述 投票:0回答:1

我正在为bash编写个人提示,我想在提示行的末尾添加上一个命令的退出状态。

例如

goofy@disney:~$ test "0" = "0"
goofy@disney:~$ test "0" = "1"                         ✔️0
goofy@disney:~$                                        ✘1

有什么方法可以实现?

bash terminal prompt
1个回答
0
投票

尝试一下\$?

Demo:

$PS1="\$?:>"
0:>test "0" = "1"
1:>test "0" = "0"
0:>test "0" = "1"
1:>
© www.soinside.com 2019 - 2024. All rights reserved.