github
  • markdown
  • wiki
  • 2012-11-07 3 views 0 likes 
    0

    내가 마크 다운 편집 모드를 사용하여 GitHub의에 위키 페이지를 편집하고 다음과 같이 쉘 스크립트 코드 형태의 블록을 삽입하려고 그러나GitHub 위키 편집 : " 033"의 대체를 피하는 법?

    ``` 
    if [ "$color_prompt" = yes ]; then 
        PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\[email protected]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 
    else 
        PS1='${debian_chroot:+($debian_chroot)}\[email protected]\h:\w\$ ' 
    fi 
    ``` 
    

    , 블록이 대신처럼 보이는 끝 :

    if [ "$color_prompt" = yes ]; then 
        PS1='${debian_chroot:+($debian_chroot)}\[SAME-43-CHAR-SEQUENCE[01;32m\]\[email protected]\h\[SAME-43-CHAR-SEQUENCE[00m\]:\[SAME-43-CHAR-SEQUENCE[01;34m\]\w\[SAME-43-CHAR-SEQUENCE[00m\]\$ ' 
    else 
        PS1='${debian_chroot:+($debian_chroot)}\[email protected]\h:\w\$ ' 
    fi 
    

    따라서 문자 시퀀스 \033을 어떤 종류의 UUID처럼 보이는 코드 SAME-43-CHAR-SEQUENCE으로 해석하는 것 같습니다. 어떻게 피할 수 있습니까? Thx

    답변

    0

    슬래시를 다른 슬래시로 이스케이프 처리하면 작동하는 것 같습니다.

    그래서, \\033

    if [ "$color_prompt" = yes ]; then 
        PS1='${debian_chroot:+($debian_chroot)}\[\\033[01;32m\]\[email protected]\h\[\\033[00m\]:\[\\033[01;34m\]\w\[\\033[00m\]\$ ' 
    else 
        PS1='${debian_chroot:+($debian_chroot)}\[email protected]\h:\w\$ ' 
    fi 
    
    \033 변경
    관련 문제