Shell Prompt Line Wrapping Issue

前端 未结 9 2106
一生所求
一生所求 2021-01-30 03:30

I\'ve done something to break my Bash Shell Prompt in OS X (10.5.7) Terminal.

This is the PS1 that I had configured:

PS1=\'\\[\\e[1;32m\\]\\h\\[\\e[0m\\]         


        
9条回答
  •  醉酒成梦
    2021-01-30 03:49

    Here's mine: it's the best one I've found, but the site where I originally found it was missing an escape character, leading to the line wrapping issue. I tinkered with it and finally got it working. It shows your user, path, and branch info with good contrast, color-wise.

    export PS1='\[\e[1;37m\]\[\e[1;32m\]\u\[\e[0;39m\]:\[\e[1;33m\]\w\[\e[0;39m\]\[\e[1;35m\]$(__git_ps1 " (%s)")\[\e[0;39m\] \[\e[1;37m\]|\[\e[0;39m\]\$'
    

    Also, add

    GIT_PS1_SHOWDIRTYSTATE=true
    

    To show a marker when a branch is "dirty" (changes to be committed exist)

    export HISTCONTROL=ignoredups
    

    Is also useful to ignore duplicates when scrolling up through bash history.

    bind "set completion-ignore-case on" 
    

    Helps too.

    Lastly,

    shopt -s checkwinsize
    

    May be helpful on OSX if issues persist.

提交回复
热议问题