オートコンプリート時に現在のディレクトリを提案しない

オートコンプリート時に現在のディレクトリを提案しない

私は長い間ZSHを使用しています。この機能はずっと前にあったようですが(古い前に).zshrcを書き換えることで、今はこの機能が時々見逃されます。 (もちろん古すぎてメモリの問題があるかもしれません。)

私が望むのは、オートコンプリート(タブタップなど)を行うときにレベル1(たとえば「..」)を超えて起動した場合、現在のディレクトリの提案が必要ないことです。

だから私がそうするなら

/usr/share$ cd ../<tab>

それから私はいいえ私の現在のディレクトリを提案として欲しい

/usr/share$ cd ../share/

問題はZSHについてですが、Bashでも実行できるかどうかを知りたいです。

ベストアンサー1

~からhttp://zshwiki.org/home/examples/compsys/ignore#ignore_parent_directory

zstyle ':completion:*:(cd|mv|cp):*' ignore-parents parent pwd

詳細も参照してくださいinfo zsh ignore-parents。以下はzsh 5.4.2で再印刷されました。

両親を無視する

 The style is tested without a tag by the function completing
 pathnames in order to determine whether to ignore the names of
 directories already mentioned in the current word, or the name of
 the current working directory.  The value must include one or both
 of the following strings:

 parent
      The name of any directory whose path is already contained in
      the word on the line is ignored.  For example, when completing
      after foo/../, the directory foo will not be considered a
      valid completion.

 pwd
      The name of the current working directory will not be
      completed; hence, for example, completion after ../ will not
      use the name of the current directory.

 In addition, the value may include one or both of:

 ..
      Ignore the specified directories only when the word on the
      line contains the substring '../'.

 directory
      Ignore the specified directories only when names of
      directories are completed, not when completing names of files.

 Excluded values act in a similar fashion to values of the
 ignored-patterns style, so they can be restored to consideration by
 the _ignored completer.

おすすめ記事