ファイル補完の表示方法を変更できますか?

ファイル補完の表示方法を変更できますか?

次の手順を実行すると、プロセスをより便利に完了できますzstyle ':completion:*:processes' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'。を使用しls -lたり、exa同様のファイル補完を実行する方法はありますか?

ベストアンサー1

洞窟探検でzshall(1)zsh 5.4.2この機能がいつ追加されたのかわからない)、次のものがあります。

   file-list
          This style controls whether files completed using  the  standard
          builtin  mechanism  are to be listed with a long list similar to
          ls -l.  Note that this feature uses the  shell  module  zsh/stat
          for  file  information;  this  loads the builtin stat which will
          replace any external stat executable.  To avoid this the follow-
          ing code can be included in an initialization file:

                 zmodload -i zsh/stat
                 disable stat

          The style may either be set to a `true' value (or `all'), or one
          of the values `insert' or `list', indicating that files  are  to
          be  listed in long format in all circumstances, or when attempt-
          ing to insert a file name, or when listing  file  names  without
          attempting to insert one.

したがって、これを使用するには、最後のコマンドの代わりに次のようにls blah/tab入力します。

$ PS1='%% ' zsh -f
% autoload -U compinit && compinit
% zstyle ':completion:*' file-list all
% mkdir blah
% touch blah/{a,b,c}
% ls blah/
-rw-r--r--   1 jhqdoe    grp             0 Sep 10 08:36 a
-rw-r--r--   1 jhqdoe    grp             0 Sep 10 08:36 b
-rw-r--r--   1 jhqdoe    grp             0 Sep 10 08:36 c

おすすめ記事