我希望在每个提示上添加一个新行。而不是光标在行上显示为
name@machine:~$ _
,
我希望它在下一行,例如:
name@machine:~$
_
Run Code Online (Sandbox Code Playgroud)
谢谢。
hto*_*que 93
打开文件~/.bashrc
(或者/etc/bash.bashrc
它是否应该对所有用户全局有效)。
找到名为 的变量PS1
。
只需将 an\n
放在PS1
变量值的末尾。
Rém*_* B. 17
.bashrc
文件首先,将以下行附加到您的~/.bashrc
文件中:
##
## INCLUDE CUSTOM `.bashrc` CODE
##
if [ -f ~/.bashrc_custom ]; then
. ~/.bashrc_custom
fi
Run Code Online (Sandbox Code Playgroud)
创建自定义文件:
touch ~/.bashrc_custom`
Run Code Online (Sandbox Code Playgroud)
最后打开它并将以下几行放入:
# File: $HOME/.bashrc_custom
# THIS FILE IS A USER-CUSTOM BASHRC FILE TO KEEP CLEAN THE DEFAULT ~/.barshrc FILE.
# PUT THERE ANY CUSTOM CODE MANUALLY ADDED BY YOU
# Add a new line at the end of the command prompt
#PS1=${PS1}\\n
PS1=${PS1%?}
PS1=${PS1%?}\n'$ '
Run Code Online (Sandbox Code Playgroud)
下一个打开的 shell 会话将如下所示:
user@host:~
$ <your-next-command-will-be-rendered-here>
Run Code Online (Sandbox Code Playgroud)
这很痛苦,但最终,由于具有自定义颜色的复杂自定义 PS1 设置,这是唯一对我有用的方法:
new_line() {
printf "\n$ "
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]$(new_line)'
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)$(new_line)'
fi
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
62826 次 |
最近记录: |