
내 Bash 프롬프트는 그 뒤의 텍스트를 삭제하거나 기록에서 너무 멀리 이동하면 자동으로 지워집니다.
로그인하면 프롬프트가 정상적으로 보입니다. 색상이 지정된 사용자 이름 주위에 흰색 대괄호가 있고 프롬프트로 흰색 >이 있지만 기록에서 두 번 위로 이동하면 기록 명령이 프롬프트를 덮어씁니다.
[stonewareslord] > #Initial prompt. stonewareslord is green
| Cursor is above this pipe symbol
[stonewareslord] > ls #Up arrow pressed once. ls was my last command. Colors are normal, ls is white
| Cursor is above this pipe symbol
pwdonewareslord] > ls #Up arrow a second time. pwd overwrite [st. pwd is white and the other colors are normal.
| Cursor is above this pipe symbol
명령을 삭제할 때도 발생합니다.
[stonewareslord] > ls #Typed command after initial prompt. stonewareslord is green
| Cursor is above this pipe symbol
[stonewareslord] > l #Deleted one character
| Cursor is above this pipe symbol
#Deleted second character (line is blank). Anything I type is white
| Cursor is above this pipe symbol
아마도 이에 영향을 미칠 수 있는 bashrc의 행은 다음과 같습니다.
color='\e[0;32m' #Green
reset='\e[0m' #Color is set back to normal (white)
prompt(){
printf "[$color%s$reset]>" `whoami`
}
PS1=""
PROMPT_COMMAND=prompt
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="%Y-%m-%d_%H:%M:%S "
export HISTFILE=~/.bash_eternal_history
readonly HOME
readonly HISTIGNORE
답변1
글쎄, 나는 그 문제를 해결할 방법을 알아 냈습니다.
PROMPT_COMMAND=prompt
다음으로 변경되었습니다:
PROMPT_COMMAND='PS1=`prompt`'
편집: 그리고 색상은 \[ \]
(즉 color='\[\e[0;32m\]'
)