ubuntu 12.04 tab键补全问题
来源:互联网 发布:网络主播常用语 编辑:程序博客网 时间:2024/06/03 08:00
最近不知道怎么了,在用bash时tab键出问题。具体描述如下:
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 tab键补全问题
- ubuntu 12.04 alt+tab无法切换窗口的问题
- ubuntu 12.04 alt+tab无法切换窗口的问题
- ubuntu 12.04 alt+tab无法切换窗口的问题
- ubuntu 12.04无法使用 Alt-Tab问题解决
- ubuntu tab键命令不能补全的问题
- ubuntu 找回 ALT+TAB
- ubuntu-tab空格修改
- ubuntu 按Tab补全报错
- 改变Ubuntu 12.04 Terminal 和 gedit 中tab的颜色
- 解决ubuntu新建用户后,tab键不能使用的问题
- 解决ubuntu 终端tab键无法命令补全的问题
- Ubuntu 16.04设置Tab长度
- 关于TAB字符问题
- TAB顺序问题
- DWZ的Tab问题
- tab切换延时问题。
- IOS tab图标问题
- Ubuntu 下环境配置
- php study 7 time date
- HTML5离线应用无法更新的定位与解决
- web 网页跳转
- vba采集新浪微博数据
- ubuntu 12.04 tab键补全问题
- _mainCRTStartup
- 模型-视图-控制器(MVC)
- Java 压缩图片
- C++空类默认函数
- oracle 8i 中文转拼音
- jxl实用技巧
- android特效集锦系列之二 仿微信导航和主菜单
- c++ new operator与operator new的区别