简体   繁体   English

无法在Mac OS X的iTerm和终端中删除整个命令

[英]Can't remove a entire command in iTerm and Terminal on Mac OS X

I'm using iTerm and Terminal in Mac OS X El Captain. 我在Mac OS X El Captain中使用iTerm和Terminal。

When I delete characters using "delete" button in the command line, it stuck at some point and don't move left further in both iTerm and Terminal. 当我在命令行中使用“删除”按钮删除字符时,它停留在某个点,并且在iTerm和Terminal中都没有向左移动。

For example, I typed 例如,我输入

%ps -aef | grep test

and then tried to remove this command entirely from the last char using "delete" button. 然后尝试使用“删除”按钮从最后一个字符中完全删除此命令。

But when I removed until e and I still had 但是当我删除直到e并且我仍然有

%ps -a

and then stuck and couldn't remove from a. 然后卡住,无法从中移除。 I can't completely remove the entire command. 我无法完全删除整个命令。 It happens so frequently and very annoying. 它如此频繁且非常烦人。

Does anyone know how to solve this issue? 有谁知道如何解决这个问题?

Someone already replied and asked some and this is my reply: 有人已经回答并问了一些,这是我的回复:

  • export PS1="\\e[\\033[35m[\\u:\\W]\\$ \\e[m " in .bash_profile 在.bash_profile中export PS1="\\e[\\033[35m[\\u:\\W]\\$ \\e[m "
  • echo $TERM output is xterm-256color delete echo $TERM输出是xterm-256color删除
  • delete key is backspace key on mac book air 删除键是mac book air上的退格键

In your prompt 在您的提示下

export PS1="\e[\033[35m[\u:\W]\$ \e[m "

bash does not know that the printable part is only bash不知道可打印部分仅仅是

export PS1="[\u:\W]\$  "

Unless told otherwise, by bracketing the nonprintable characters with \\[ and \\] , it assumes the whole string is printable, counting each ordinary character as one column ( \\u\u003c/code> and \\W mean something that the shell computes for itself). 除非另有说明,否则通过将不可打印字符括在\\[\\] ,它假定整个字符串都是可打印的,将每个普通字符都计为一列( \\u\u003c/code>\\W表示shell为其自身计算的内容)。

You might have meant something like this: 您可能已经说过这样的意思:

export PS1="\[\033[35m\][\u:\W]\$ \[\e[m\] "

(trimming the spurious \\e[ which does nothing useful). (修剪虚假的\\e[没什么用)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM