分享一个在命令行中通过拼音就能进入中文目录的方法
Tofloor
poster avatar
litsdeepin
deepin
2018-02-21 13:25
Author
本帖最后由 litsdeepin 于 2018-8-20 05:53 编辑

先给出作者的github https://github.com/petronny/pinyin-completion 致敬!

前言:
在命令行中进入中文目录,每次都要切换到中文输入法才能进入,非常麻烦。很希望可以通过拼音就能进入中文目录,这样就不用总是切换输入法了,在网上找了找,还真有,用了之后感觉非常棒,特地分享给大家。

方法如下:
1. 下载作者的包到本地。(随便下载到哪里都好,随你喜欢,我是放在了/opt里
  1. git clone https://github.com/petronny/pinyin-completion.git
Copy the Code
2. 进入刚刚下载好的目录
  1. cd pinyin-completion
Copy the Code
3. 执行安装命令
  1. sudo ./setup.py install
Copy the Code
4. 添加下列命令到bash或zsh的配置文件,如果用的bash,修改~/.bashrc,如果用的zsh,修改~/.zshrc (我这里用zsh为例)
  1. source /opt/pinyin-completion/shell/pinyin-comp.zsh
Copy the Code
(注意:我的是安装目录在/opt下,请把/opt替换为自己的下载位置,bash用户请将末尾的zsh替换为bash)
5. 让配置生效
  1. source ~/.zshrc
Copy the Code
(bash用户,请使用 source ~/.bashrc)

使用方法:
1. cd 到中文目录
  1. deepin@deepin: $ ls .
  2. 科学大观 Downloads     Documents
  3. deepin@deepin: $ cd kx
Copy the Code
例如:我的主目录下有 科学大观 目录,使用的时候,输入cd,然后顺序输入科学大观的首字母(注:输入全拼无效),然后按 Tab 便出现了候选的中文目录
更多用法请参考作者的github
2. vi 中文文件名
用法同上
3. 必须顺序输入拼音首字母才有效(当然,不用输入所有汉字的首字母)

效果如下:
Reply Favorite View the author
All Replies
辉夜
deepin
2018-02-21 13:45
#1
这么早Orz
Reply View the author
litsdeepin
deepin
2018-02-21 13:55
#2

哈哈,你也很早啊~~~
Reply View the author
jingle
deepin
2018-02-21 21:25
#3
好东西
Reply View the author