请参阅下面我的编辑,这并不完全是Shell 提示自定义和 cmd 行为的重复
我reverse-search在 CLI 中的功能坏了,我不知道如何修复它......
当我按 ctrl+r 并搜索我之前执行的命令时,找到它然后按向右箭头键使用它,输出已损坏。下面是一个例子:
# I reverse-searched the word "test" then pressed right arrow
yoshiji@x1carbon:~/path/to/git/folder (master) $ch)`test': rake test
# ^^^^^^^^^^ weird output
# ^ cursor right there
Run Code Online (Sandbox Code Playgroud)
它还将我的光标“移动”到不同的位置。如果我按回车,就会执行正确的命令(rake test在这种情况下),所以这意味着显示的文本与实际执行的不同。
我知道这很可能与我PS1在 my 中的导出有关~/.bashrc,所以这里是这个文件的最后几行:
# Git branch in prompt.
git_branch() {
branch=$(__git_ps1 2> /dev/null)
if [ "$branch" = " (master)" ]; then
echo -e "\033[33m${branch}\033[00m" # yellow
elif [ "$branch" = "" ]; then
echo …Run Code Online (Sandbox Code Playgroud)