![입력을 시작하면 길게 생성된 Bash 프롬프트가 잘못 표시됩니다.](https://linux55.com/image/34642/%EC%9E%85%EB%A0%A5%EC%9D%84%20%EC%8B%9C%EC%9E%91%ED%95%98%EB%A9%B4%20%EA%B8%B8%EA%B2%8C%20%EC%83%9D%EC%84%B1%EB%90%9C%20Bash%20%ED%94%84%EB%A1%AC%ED%94%84%ED%8A%B8%EA%B0%80%20%EC%9E%98%EB%AA%BB%20%ED%91%9C%EC%8B%9C%EB%90%A9%EB%8B%88%EB%8B%A4..png)
계산하는 데 시간이 걸리는 Git 작업 트리 상태가 포함되어 있기 때문에 생성하는 데 시간이 걸리는 Bash 프롬프트가 있습니다. 때로는 명령이 나타나기 전에 명령을 입력하기 시작했지만 명령이 잘못 줄 바꿈되는 경우가 있습니다.
터미널에서 본 내용은 다음과 같습니다.
# I start typing:
some command...
# then the prompt appears:
some command...username [branch*] some/directory $ some command...
# then I type some more, causing the command to wrap:
some command...username [branch*] some/directory $ some command...wra
pping text 1
# and when I continue typing, the text overwrites the second line:
some command...username [branch*] some/directory $ some command...wra
wrapping text 2
이것을 방지하는 방법을 아시나요?
내 Bash 프롬프트가 설정되는 방법은 다음과 같습니다.
# in .bashrc:
PROMPT_COMMAND="PS1=\`/home/username/my-prompt.sh\`"
# in /home/username/my-prompt.sh:
$PROMPT=...
$PROMPT+=...
echo -ne $PROMPT
나는 $PROMPT 에서 모든 합계를 올바르게 설정했다고 생각합니다 \[
. \]
이 문제는 프롬프트가 나타나고 명령이 래핑되기 전에 입력을 시작한 경우에만 발생합니다.
답변1
프롬프트를 생성할 때 터미널 출력을 비활성화하면 작동할 수 있습니다.
PROMPT_COMMAND="PS1=\$(stty -echo)\`/home/username/my-prompt.sh\`\$(stty echo)"
답변2
다음 명령을 사용하여 터미널을 정상 모드로 설정하는 것이 좋습니다(농담입니다)
stty sane # I hope it'll help and bring back the working of default prompt.