网上大量的关于添加PS1的文章都说将~/.profile文件修改如下: PS1=’\e[0;32m\h\e[0m:\W \u\$’ 其实这样bash在利用readline计算字符数量的时候是会将那些\e[m的字符都计算在内的。这样就会导致不能正确的自动换行了。事实上正确的做法是: PS1=’\[\e[0;32m\]\h\[\e[m\]:\W \u\$’ 需要在这些不显示的字符前后包上 \[ \], 这样bash就不会将自动换行计算错误。
Tag: terminal
Mac OS X Terminal shortcut
(转自stackoverflow,略改) On Mac OS X 10.7 – the following keyboard shortcuts work by default. Meta-Right to jump forward by a word Meta-Left to jump backward by a word I have observed that default emacs key-bindings for simple text navigation seem to work on bash shells. You can use Meta-d to delete a word starting from… Continue reading Mac OS X Terminal shortcut