歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Ubuntu 11.04 bash補全的問題

Ubuntu 11.04 bash補全的問題

日期:2017/2/28 16:13:31   编辑:Linux教程

這幾天使用Ubuntu的命令行時,總是莫名其妙的多少空格。

例如$ls /var

在正常情況下應該會出現$ls /var/

但是我現在成了$ls /var空格

老兄,/var是一個目錄啊,不是一個文件,不能在後不亂添空格的。

這應該是bash補全出了問題。

產生問題的原因:https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/769866/comments/10

意外的收獲,自己寫程序時,在linux環境中也來個參數補全。

秘密就在/etc/bash_completion.d中。

Ubuntu 11.04, aka Natty Narwhal, was released on April 28th and so naturally I chose to break my perfectly functioning laptop to see what was new. That “upgrade” button really needs to read something like, “download and install new software then spend a week scouring the internet for information and trying to fix all the shit that just broke.” But that’s probably a little too verbose for the UX people.

What broke?

To be completely fair, most things did not break. It was mainly KDE (my default X session), that new Unity business, “classic” Gnome (not entirely broken, but severely wounded), and bash shell tab completion. Or, in other words, just a number of the most important parts for actually “using” my computer to “do things.” I apologize for blowing things out of proportion.

I’ve gotten KDE (and Gnome, but not Unity — it refuses to believe my hardware is sufficient to run it) back up and running now after deleting tons of old configuration files (.kde*, .gconf, selectively under .config…and a bunch of other stuff I’ve forgotten) and also by accepting that the combination of Compiz + KDE is no longer usable and switching out Compiz for KDE’s native window manager, KWin. I had originally ditched KWin because it didn’t play nice (broken desktop effects and resource hogging and slow and crash-y) with fglrx (the radeon graphics driver.) KWin runs with direct rendering and GLSL shaders disabled (on my ATI Mobility Radeon HD 3650) and it’s (mostly) not as good as Compiz + KDE used to be. But it is 90% as good and the best and only real current option.

About that bash completion…

And then there was the broken bash completion (<tab>-completion.) For example, typing “ls /et<tab>” yielded “ls /etc ” and not “ls /etc/” (note the extra space and lack of closing slash at the end.) Reinstalling bash-completion did not fix this problem for me. What did work was removing bash-completion, renaming /etc/bash_completion.d//etc/bash_completion.d.bak/, and then reinstalling bash-completion.


user@machine:~$sudo apt-get purge bash-completion
user@machine:~$sudo mv /etc/bash_completion.d /etc/bash_completion.d.bak
user@machine:~$sudo apt-get install bash-completion

After reinstalling bash-completion, /etc/bash_completion.d/ reappeared. I diffed the two directories and the new one had way more stuff so I just rm -rfed the old one. I’m happy to say my bash completion is working again and I’m going to file this problem under ‘s.’ For “solved.”

Conclusion

Well, that was fun! Looking forward to willingly breaking my computer again in another 6 months! See you then!

Copyright © Linux教程網 All Rights Reserved