我想定义一个提示,用颜色指示命令是否正确执行以及是否找到命令。至于现在我有这样的东西,但我不能正常工作。
PS1="\`COMMAND_RESULT=\$\?;
if [ $COMMAND_RESULT -eq 127 ]; then echo \[\e[33m\] ---=== Command not found ===--- ;
elif [ $COMMAND_RESULT -ne 0 ]; then echo \[\e[33m\]---=== \[\e[31m\]Oh noes, bad command \[\e[33m\]==---;
fi\`
\n\[\e[0;37m\][\[\e[1;31m\]\@\[\e[0;37m\]]
\[\e[0;32m\]\u\[\033[1;33m\]@\[\033[0;32m\]\h
至于现在我在 bash start 上收到此错误:
-bash: [: -eq: unary operator expected
-bash: [: -ne: unary operator expected