LoginSignup
11
8

More than 5 years have passed since last update.

zshで途中の文字から補完できるようにする

Posted at

oh-my-zsh を入れると cd などで、ディレクトリ名の最初から入力しなくても、途中の文字から補完してくれる:

$ ls
machine-learning-ex1 ... machine-learning-ex6
$ cd 6 [Tab]
$ cd machine-learning-ex6

つまり、

$ cd m [Tab]
$ cd machine-learning-ex

と先頭の文字から補完してくれるのは当然だけれども、途中の文字 6 でも補完してくれる。しかし、いろんな設定がごちゃ混ぜに入っている oh-my-zsh は入れたくないので、この機能だけ入れたいとしよう。

その設定は ~/.oh-my-zsh/lib/completion.zsh に書いてあって、最小限の設定は:

autoload -U compinit; compinit
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
11
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
8