终端下拼音补全中文名称和路径

{ 撰文/BiFF }

在 Linux 下打字飞快的朋友,遇到中文目录和文件名立马就慢下来了, 有 2 种选择:

  1. 切换成中文输入一两个汉字,然后按 TAB 补全
  2. 动用鼠标复制

现在有第三种选择了 :)

用拼音补全命令行中的中文名称和路径

实验目录如下:

biff@lenovo:/domain/WorkSpace$ ls
SVN培训 全球眼 浙江建行 浙江农信

使用: (输完后按 TAB 键自动补全)

cd S <tab> 进入[SVN培训]
cd q <tab> 进入[全球眼]
cd z <tab> 自动补全[浙江]
cd zj <tab><tab> 提示[浙江建行 浙江农信]备选
cd 浙江j <tab> 进入[浙江建行]
cd zjj <tab> 进入[浙江建行]
cd zj1 <tab> 进入[浙江建行]
cd zj2 <tab> 进入[浙江农信]

这第 3 种方法是前两种方法不能比的,自已用了半个月了,超爽!

共享给大家,有意见再改。

下载软件包,解压,参考 install.sh 进行安装(不需要 root 权限)。

{ Thanks BiFF. }

Read More:

  • No related posts

56 Comments

  1. 1 dilxat Commented @ 2009-12-11 18:09Reply to this comment

    这个nb。。

  2. 2 siziki Commented @ 2009-12-11 18:11Reply to this comment

    看起来好强大阿

  3. 3 Pepino Commented @ 2009-12-11 18:14Reply to this comment

    不知多音字和汉英混写的文件名怎样

  4. 4 rem1x Commented @ 2009-12-11 18:20Reply to this comment

    很久以前,不知道在哪里看到过这个东东。

  5. 5 somebody(莫多) Commented @ 2009-12-11 18:27Reply to this comment

    哦。这么爽。 那要试试了。 一般都是打个中文再补全的。

  6. 6 upsuper Commented @ 2009-12-11 18:27Reply to this comment

    太强大了!

  7. 7 Iven Commented @ 2009-12-11 18:31Reply to this comment

    貌似以前看到过……不过好像那个不是 for bash 的……

  8. 8 BiFF Commented @ 2009-12-11 18:50Reply to this comment

    支持多音字 音乐 可以用 yy 或者 yl

    支持模糊拼音 农信 可以用 nx 或者 lx ( 要配置环境变量 export CHSDIR={'l':'n'} )

    http://groups.google.com/group/binsos/browse_thread/thread/1951b77a2cf4bfab

  9. 9 Yao Commented @ 2009-12-11 18:57Reply to this comment

    很实用,以前为了方便我home下的目录都是命名成英文的

  10. 10 paopao Commented @ 2009-12-11 19:08Reply to this comment

    试了一下,确实很爽

  11. 11 niclau Commented @ 2009-12-11 19:10Reply to this comment

    这个很强大...

  12. 12 yuany Commented @ 2009-12-11 19:11Reply to this comment

    很爽阿~~!

  13. 13 yhlfh Commented @ 2009-12-11 19:13Reply to this comment

    这个狂赞啊!真是创意无限啊!

  14. 14 oldherl Commented @ 2009-12-11 19:43Reply to this comment

    这个必须赞,创意非常好! 从此不用把文件名全写成英文了! 可以想办法加上生僻字读音支持。

  15. 15 adam8157 Commented @ 2009-12-11 20:11Reply to this comment

    赞...roylez的好像也写了个类似脚本....

  16. 16 shellexy Commented @ 2009-12-11 20:15Reply to this comment

    赞~

  17. 17 Alpha Commented @ 2009-12-11 20:24Reply to this comment

    反正我是尽量不要用中文名字作目录的。

  18. 18 cynic Commented @ 2009-12-11 20:39Reply to this comment

    @Alpha

    还有文件~~~总不能都不用中文名吧

  19. 19 simsilver Commented @ 2009-12-11 20:48Reply to this comment

    我这儿不能用..... 不知道为啥,用的locale是en_US.UTF-8

  20. 20 Kingway Commented @ 2009-12-11 20:52Reply to this comment

    @simsilver: 我的locale也是en_US.UTF-8,可以正常使用啊。

  21. 21 Kingway Commented @ 2009-12-11 20:53Reply to this comment

    有没有谁懂得原理?请说说。

  22. 22 黑日白月 Commented @ 2009-12-11 20:54Reply to this comment

    狂赞~

    不过最近好像用不到中文……

  23. 23 ybyygu Commented @ 2009-12-11 21:11Reply to this comment

    应该必须装bash_completion才行

  24. 24 simsilver Commented @ 2009-12-11 21:17Reply to this comment

    Fedora 12 默认没装bash-completion包,装上之后就可以用了.....

  25. 25 Daniel King Commented @ 2009-12-11 21:29Reply to this comment

    真好用,可以申请加入各大发行版了

  26. 26 iiiii Commented @ 2009-12-11 21:33Reply to this comment

    看了下install.sh,有点小疑问,是不是这个东西只支持bash?还有为什么是先mkdir和cp文件后再来判断是不是用的bash?

  27. 27 BiFF Commented @ 2009-12-11 21:45Reply to this comment

    @iiiii:

    install.sh 小改了,先判断是不是bash,不是就退出! 以前没注意这个细节 :( ,下次有重大问题再一起发布

  28. 28 xifs Commented @ 2009-12-11 21:51Reply to this comment

    我的目录很少中文的。就是为了方便。 这下可以稍稍用些中文了。

  29. 29 Grissiom Commented @ 2009-12-11 22:40Reply to this comment

    有没有 zsh 的呢?……

  30. 30 fanhe Commented @ 2009-12-11 22:44Reply to this comment

    这的确是个好东西.great job!

  31. 31 improve Commented @ 2009-12-11 22:46Reply to this comment

    设置补全的时候忽略大小写之后,echo "set completion-ignore-case on" >> ~/.inputrc 比如 a中 A文 按aw应该能补全A文,但其实非得用Aw才行,一点点的不方便

  32. 32 improve Commented @ 2009-12-11 22:48Reply to this comment

    设置补全的时候忽略大小写

    echo "set completion-ignore-case on" >> ~/.inputrc

    之后:

    比如有如下文件名

    A中文

    按az应该能补全A中文,但其实非得用Az才行,一点点的不方便

  33. 33 delectate Commented @ 2009-12-11 22:55Reply to this comment

    爽翻

    不知道tty下能用否……

  34. 34 bingmou Commented @ 2009-12-11 23:00Reply to this comment

    很少目录是中文的了……

  35. 35 Linux Chinese User Group Commented @ 2009-12-11 23:21Reply to this comment

    tty下应该不能用

  36. 36 Daze Commented @ 2009-12-11 23:58Reply to this comment

    试了一下,不错,就是在一些命令中没用,像 file、ll(我设置的 ls -l 别名),但我的 ls 也是别名却可正常补全,不知怎么回事?

  37. 37 realzhang Commented @ 2009-12-12 0:04Reply to this comment

    能不能支持fish?谢谢

  38. 38 BiFF Commented @ 2009-12-12 2:25Reply to this comment

    @Daze:

    不被支持的支持的命令手工加一条记录到.bashrc就行了
    比如file命令: complete -o filenames -F _filedir_xspec file

    针对alias的问题通过增加函数解决了,运行没问题就发布

  39. 39 BiFF Commented @ 2009-12-12 2:27Reply to this comment

    上条回复 filedir 斜体字是前后有下划线,注意了

  40. 40 嘉佑 Commented @ 2009-12-12 9:04Reply to this comment

    不要也罢,我一般不喜欢使用中文来命名文件夹。

  41. 41 eagle Commented @ 2009-12-12 10:10Reply to this comment

    靠,昨天才把中文文件夹前加上数字,方便tab……今天……

  42. 42 HalloKetty Commented @ 2009-12-12 11:21Reply to this comment

    非常方便非常好

  43. 43 lilydjwg Commented @ 2009-12-12 12:03Reply to this comment

    期待支持 zsh

  44. 44 oldherl Commented @ 2009-12-12 12:34Reply to this comment

    @Linux Chinese User Group: 经过试验,tty下能用。

    当然你的tty最好要支持中文显示,比如用fbterm(可以不装ucimf输入法)

  45. 45 zsl1005 Commented @ 2009-12-12 17:22Reply to this comment

    报告,如果再nautilus中用右键在此处打开终端的方式打开shell,则补全不可用

  46. 46 BiFF Commented @ 2009-12-12 18:33Reply to this comment

    @zsl1005: 那是natiuls插件的bug,那家伙压根就没导入.bashrc,ub9.10有这个问题,8.10正常

  47. 47 too Commented @ 2009-12-12 21:31Reply to this comment

    好用!!! 解决了一个麻烦。支持。 不过在home目录生成一个bin目录,能设置为隐藏么? e,还有,虽然我也不会删除,但是我想问这个要删除是直接删掉$home/bin文件夹就ok了么?

  48. 48 BiFF Commented @ 2009-12-12 22:17Reply to this comment

    等 deb 包吧,

    chsdir 放 /usr/sbin/ 下面 chscompletion 放 /etc/bashcompletion.d/ 下面

    .bashrc 不需要配置

  49. 49 owwbu Commented @ 2009-12-12 23:57Reply to this comment

    很赞,很爽。都巴不得多建几个中文目录了。哈哈

  50. 50 wangjl Commented @ 2009-12-13 0:29Reply to this comment

    牛,等deb包

  51. 51 Daze Commented @ 2009-12-13 1:02Reply to this comment

    @BiFF: 多谢提醒! 装好后用了一天,发现进入终端和补全时(包括英文)慢了很多,先以为是这个小软件的问题,后来一查不是,而是它所依赖的 bash-completion 引起的。 折腾了一阵,发现 bash-completion 很让人纠结,一是有点影响正常操作(慢)、一是有点“恐怖”(键入 set 看看)。但好处也还是有的,可以补全很多东西,连 pacman 时的软件包名也可以补全。

  52. 52 sylecn Commented @ 2009-12-14 1:30Reply to this comment

    很实用,支持。

  53. 53 第三眼 Commented @ 2009-12-14 13:05Reply to this comment

    这个牛!收藏了

  54. 54 Jimi Commented @ 2009-12-16 12:18Reply to this comment

    相当不错,感谢楼主分享。。

  55. 55 jiqing Commented @ 2009-12-17 9:31Reply to this comment

    确实是实用的好东西。

  56. 56 ys_sunshine Commented @ 2009-12-23 16:03Reply to this comment

    唉。。不知道为什么,我也用不了。。。