私はこのbashの補完ファイルを持っているbash自動補完で第1レベルのサブディレクトリのみを表示するには?
#/etc/bash_completion.d/mycommand
_mycommand()
{
local cur
COMPREPLY=()
_init_completion || return
#Variable to hold the current word
cur="${COMP_WORDS[COMP_CWORD]}"
#array variable COMPREPLY
dirs=('Rootdir/
Secondrootdir/
Rootdir/Subdir/
Secondrootdir/Anothersubdir/
Secondrootdir/Thirdsubdir/
Secondrootdir/Anothersubdir/Subsubdir/'
)
COMPREPLY=($(compgen -W "$dirs" "$cur"))
}
#Assign the auto-completion function _mycommand for our command mycommand.
complete -F _mycommand mycommand
私は二回、私は以下を参照してください。複数の選択肢を持っているし、TABを打つ:
$ mycommand Secondrootdir/
Secondrootdir/
Secondrootdir/Anothersubdir/
Secondrootdir/Anothersubdir/Subsubdir/
Secondrootdir/Thirdsubdir/
しかし、私は、入力された現在の唯一のレベルの深いサブディレクトリを見てみたいですこのようなSecondrootdir
:
$ mycommand Secondrootdir/
Anothersubdir/ Thirdsubdir/
CDコマンドは、ビジネスだけでなく
$ cd Music/
kattymusic/ Playlists/ Relax/
を行います。しかし、私は、CDの自動補完がどのように機能するかを理解することはできません。
誰でも助けてください、よろしいですか?
号のように見えますリモートサーバー。私はAPIを使ってそれらのリストを受け取ることができます。 – Oleg
ありがとうございます。良い例ですが、私は反対のことが欲しいです。 – Oleg
私はこれにもっと力を注いで成功することを願っています。 – Oleg