Não sugerir diretório atual no preenchimento automático

4

Eu sou um usuário de longa data da ZSH. Parece-me que eu costumava ter essa funcionalidade há muito tempo, mas depois reescrevi meu .zshrc (há muito tempo) e agora sinto falta dessa funcionalidade de vez em quando. (Claro que, há muito tempo, minha memória pode estar com defeito.)

O que eu quero é que quando eu estiver preenchendo automaticamente (como pressionar a aba etc.), então eu não quero sugestões do meu diretório atual se eu estiver começando de 1 nível acima (ie, '..') ou mais.

Então, se eu fizer

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

então eu não quero meu diretório atual como uma sugestão

/usr/share$ cd ../share/

A pergunta é para o ZSH, mas eu adoraria saber se isso pode ser feito no Bash também.

    
por Anupam Srivastava 23.03.2018 / 08:46

1 resposta

4

Em link

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

Veja também info zsh ignore-parents para detalhes. Reproduzido abaixo para zsh 5.4.2:

ignore-parents

 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.
    
por 23.03.2018 / 11:10