shell提示符换行问题 [英] Shell Prompt Line Wrapping Issue

查看:251
本文介绍了shell提示符换行问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了一些打破我的Bash shell提示符在OS X(10.5.7)端子。

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

这是我所配置的PS1:

This is the PS1 that I had configured:

PS1='\[\e[1;32m\]\h\[\e[0m\]:\[\e[1;34m\]\w\[\e[0m\]\$ '

据我可以告诉我的颜色正确的命令逃逸。然而,当我上下滚动在我的命令历史记录我经常换行的问题,如果历史命令换到多行。

As far as I can tell I have the color commands escaping correctly. However when I scroll up and down in my command history I often get line wrapping issues if the historic commands wrap onto multiple lines.

我简化我的提示以下内容:

I simplified my prompts to the following:

PS1='\[\e[1m\]\h:\w\$ \[\e[0m\]'
PS2='> '

我仍然看到类似这样的:

And I still see something like:

localhost:~/Library/Application Support/Firefox/Profiles/knpmxpup.Defau
lt/extensions/{1A2D0EC4-75F5-4c91-89C4-3656F6E44B68}$ expocd \{1A2D0EC4-7
5F5-4c91-89C4-3656F6E                                           export PS1="\[
\e[1;32m\]\h\[\e[0m\]:                                          cd Library/Appl
ication\ Support/

我也试过 \\ 033 而不是的\\ E 。我只是包括PS2那里的信息,我并没有改变,从安装默认。如果我完全删除颜色codeS则一切正常,任何想法?

I've also tried \033 instead of \e. I just included PS2 up there for information, I haven't changed that from the install default. If I completely remove the color codes then everything works fine, any ideas?

推荐答案

在猛砸换行的问题早已不是什么新鲜事。咨询邮件列表,也许有这方面的又一错误。

Line wrapping issues in Bash are nothing new. Consult the Mailinglist, maybe there's yet another bug regarding this.

您不能做太多超过标记不可打印的字符,其余的必须由提示code来完成。

You can't do much more than tagging unprintable characters, the rest must be done by the prompting code.

这篇关于shell提示符换行问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆