ubuntu 12.04 tab键补全问题
2013-10-12 12:12
190 查看
最近不知道怎么了,在用bash时tab键出问题。具体描述如下:
tab 键自动补全文件夹时,不会自动添加反斜杠/,而是会多加一个空格。
I get
So I cannot further tab complete. I have to backspace to delete the extra space.
Normally I want to get:
方法一:
来自:https://bugs.launchpad.net/ubuntu/+source/acroread/+bug/769866第10楼的方案,原文如下:
I believe there is a bug on line 1587 of /etc/bash_completion, the "-o default" on that line should be changed to "-o filenames".
I haven't checked if 10.10 had "-o default". If it did, then I expect the changed behaviour was due to a change in the readline library. "-o default" means "tell readline to do what it thinks is default", and that may have worked in 10.10 but not in 11.04,
due to a readline library change. So I think it's better to say "-o filenames" which tells readline what we want.
The reason why it works OK for root but not for the normal user is, the /etc/bash-completion script is called by $HOME/.bashrc, and this call is present in the user's .bashrc but commented out in root's .bashrc (at least on the system that I recently upgraded
from 10.10 to 11.04).
I'm getting bash completion problems and I never had acroread installed on this system, so it can't be acroread in my case.
With "-o default", if I type: less /t <tab>
it expands to: less /tmp (space)
instead of less /tmp/
(but "cd /t <tab>" is OK)
"complete" is documented in "man bash" under the heading SHELL BUILTIN COMMANDS. For "-o default", it says "Use readline's default filename completion if the compspec generates no matches." For "-o filenames", it says "Tell readline that the compspec generates
filenames, so it can perform any filename-specific processing (like adding a slash to directory names, quoting special characters, or suppressing trailing spaces)."
I tried changing the "-o default" to "-o filenames" and everything worked as expected.
I have not experienced a problem with "cd", only with "less" etc.
大概意思是说,-o default 参数用的是readline的默认的文件补全,而-o filenames 告诉readline 用全路径名来产生文件名,上面的那个全路径名拼错了,是comspec。
用了这个方法后,基本上的命令都解决了,会自动补全文件夹名(加反斜杠,而不是补全后加一空格)。但是问题又出现了,当用python来运行某个程序时又出现了同样的问题了。也就是说上面的方法只是解决了部分命令的问题,并没有彻底解决问题。
方法二:
There is also a bug in the adobereader-enu (acroread) package that breaks bash completion. In this case
you can just delete the symlink:
acroread provides a bash-completion script
that has a function called _filedir, but the default bash-completion in the system has a function with the same name, hence a conflict that causes the issue the OP saw.
You have two options:
- If you don't use acroread from terminal that much, just delete /etc/bash_completion.d/acroread.sh,
as root:
CODE: SELECT ALL
- If you do use it from terminal, you'll have to rename the function manually,
this command should take care of it:
CODE: SELECT ALL
c.f. https://qa.mandriva.com/show_bug.cgi?id=61635
最后,知道了如果不从terminal中使用acroread就可以直接删除acroread.sh,不会影响到正常的adobereader的使用。但是想比较完美的解决这个问题可以输入上面那个命令 ,但是一定要谨慎。
具体参考来自网站:
https://forums.mageia.org/en/viewtopic.php?f=7&t=886
https://bugs.launchpad.net/ubuntu/+source/acroread/+bug/769866
https://qa.mandriva.com/show_bug.cgi?id=61635
http://forums.adobe.com/thread/745833
http://www.linuxidc.com/Linux/2011-06/37120.htm
http://stackoverflow.com/questions/11981764/bash-tab-completion-adds-extra-space-after-the-first-completion
http://stackoverflow.com/questions/14996391/bash-tab-completion-issues-with-ubuntu-12-04
tab 键自动补全文件夹时,不会自动添加反斜杠/,而是会多加一个空格。
a@b:~$ls Docu <TAB>
I get
a@b:~$ls Documents |(<-this is the cursor, so there is an extra space afer Documents)
So I cannot further tab complete. I have to backspace to delete the extra space.
Normally I want to get:
a@b:~$ls Docu <TAB> a@b:~$ls Documents/ <TAB> a@b:~$ls Documents/foo/ <TAB> a@b:~$ls Documents/foo/bar.txt
方法一:
来自:https://bugs.launchpad.net/ubuntu/+source/acroread/+bug/769866第10楼的方案,原文如下:
I believe there is a bug on line 1587 of /etc/bash_completion, the "-o default" on that line should be changed to "-o filenames".
I haven't checked if 10.10 had "-o default". If it did, then I expect the changed behaviour was due to a change in the readline library. "-o default" means "tell readline to do what it thinks is default", and that may have worked in 10.10 but not in 11.04,
due to a readline library change. So I think it's better to say "-o filenames" which tells readline what we want.
The reason why it works OK for root but not for the normal user is, the /etc/bash-completion script is called by $HOME/.bashrc, and this call is present in the user's .bashrc but commented out in root's .bashrc (at least on the system that I recently upgraded
from 10.10 to 11.04).
I'm getting bash completion problems and I never had acroread installed on this system, so it can't be acroread in my case.
With "-o default", if I type: less /t <tab>
it expands to: less /tmp (space)
instead of less /tmp/
(but "cd /t <tab>" is OK)
"complete" is documented in "man bash" under the heading SHELL BUILTIN COMMANDS. For "-o default", it says "Use readline's default filename completion if the compspec generates no matches." For "-o filenames", it says "Tell readline that the compspec generates
filenames, so it can perform any filename-specific processing (like adding a slash to directory names, quoting special characters, or suppressing trailing spaces)."
I tried changing the "-o default" to "-o filenames" and everything worked as expected.
I have not experienced a problem with "cd", only with "less" etc.
大概意思是说,-o default 参数用的是readline的默认的文件补全,而-o filenames 告诉readline 用全路径名来产生文件名,上面的那个全路径名拼错了,是comspec。
用了这个方法后,基本上的命令都解决了,会自动补全文件夹名(加反斜杠,而不是补全后加一空格)。但是问题又出现了,当用python来运行某个程序时又出现了同样的问题了。也就是说上面的方法只是解决了部分命令的问题,并没有彻底解决问题。
方法二:
There is also a bug in the adobereader-enu (acroread) package that breaks bash completion. In this case
you can just delete the symlink:
rm /etc/bash_completion.d/acroread.sh
acroread provides a bash-completion script
that has a function called _filedir, but the default bash-completion in the system has a function with the same name, hence a conflict that causes the issue the OP saw.
You have two options:
- If you don't use acroread from terminal that much, just delete /etc/bash_completion.d/acroread.sh,
as root:
CODE: SELECT ALL
su rm -fv /etc/bash_completion.d/acroread.sh
- If you do use it from terminal, you'll have to rename the function manually,
this command should take care of it:
CODE: SELECT ALL
su sed -i 's,_filedir,_acroread_filedir,' /usr/local/Adobe//Adobe/Reader9/Resource/Shell/acroread_tab
c.f. https://qa.mandriva.com/show_bug.cgi?id=61635
最后,知道了如果不从terminal中使用acroread就可以直接删除acroread.sh,不会影响到正常的adobereader的使用。但是想比较完美的解决这个问题可以输入上面那个命令 ,但是一定要谨慎。
具体参考来自网站:
https://forums.mageia.org/en/viewtopic.php?f=7&t=886
https://bugs.launchpad.net/ubuntu/+source/acroread/+bug/769866
https://qa.mandriva.com/show_bug.cgi?id=61635
http://forums.adobe.com/thread/745833
http://www.linuxidc.com/Linux/2011-06/37120.htm
http://stackoverflow.com/questions/11981764/bash-tab-completion-adds-extra-space-after-the-first-completion
http://stackoverflow.com/questions/14996391/bash-tab-completion-issues-with-ubuntu-12-04
相关文章推荐
- ubuntu 12.04 alt+tab无法切换窗口的问题(转载)
- ubuntu 12.04无法使用 Alt-Tab问题解决
- ubuntu 12.04 alt+tab无法切换窗口的问题
- ubuntu 12.04 alt+tab无法切换窗口的问题
- Ubuntu14.04系统Tab键不能自动补全问题解决
- ubuntu tab键命令不能补全的问题
- 解决ubuntu 终端tab键无法命令补全的问题
- Ubuntu系统Tab键不能自动补全问题解决
- ubuntu 12.04 alt+tab无法切换窗口的问题
- Ubuntu 12.04安装 iscsi服务遇到的问题
- Ubuntu 12.04关于libgl1-mesa-glx:i386安装的问题
- Ubuntu 12.04 LTS 中文txt文件显示乱码问题
- 关于thinkpad t400 安装Ubuntu 12.04 后的几个问题
- 【计算机常见问题】Ubuntu 12.04中xrdp远程客户端连接配置问题
- ubuntu 12.04 64位,安装mysql-workbench问题解决记录
- 在Linux mint 13 (Ubuntu 12.04)上安装LAMP时遇到的问题的解决方法
- Fedora17/Ubuntu 12.04 装 VMware Workstation 8.0.4/8.0.3 问题
- Ubuntu 12.04 安装 Tomcat8 遇到的问题
- Ubuntu_Ubuntu 12.04下安装wine后出现问题总结
- 解决linux终端按tab不能自动补全的问题