2017-05-30 12 views
1

私のzshにはいくつかの補完機能がありますが、私は理解しておらず、変更箇所を見つけることができません。私は2つの問題を抱えています。彼らは私の問題に対して同様の "修正"をしていると思われます。私は、高度な補完機能を取得するためにzshタブの完了動作を制限する

autoload -Uz compinit 
compinit 

とzshの補完システムを初期化しますが、私はまた私がcompinitなしではありません、次のような問題を取得します。まず

は、私は私のホームディレクトリにmydirと呼ばれるディレクトリを持つことが起こると、残念ながら、mydirというユーザーも存在します。私は自分のディレクトリに変更してから、タブ補完を使用する場合、すなわち

cd mydir/<TAB> 

私は~mydir/ために利用可能なすべてのディレクトリと一緒に~myusername/mydir/のコンテンツディレクトリを取得します。私はすでに.zloginファイルに

zstyle ':completion:*' users myusername 

を入れてみましたが、それは唯一のユーザ名自体の完成とその後のないディレクトリを変更しません。他のユーザーのホームディレクトリの完成を拒否するようなスイッチがありますか?あるいは、現在のディレクトリの補完が補完メニューの最初に表示されている場合は、既に有効です。

2番目:私のホームディレクトリにあるsetup-file-with-a-long-name.shというスクリプトを作成しました。私は

source setup-file-with-a-long-name.sh 

を経由して、それを実行したいとき、私は最初の数文字で始まる、私は<TAB>を押すと、私は、システムがインストールされ、私の$PATH上のどこかにおそらくある実行可能ファイルの多くのリストを取得するが、私ドンこれらすべてのファイルを気にする必要はなく、私のファイル(現在のディレクトリ内の唯一のファイル)は、メニューの最初に表示され、<TAB> <TAB>以上でアクセス可能で、最初のファイルの後に受け入れられるようにしてください。<TAB> (いずれかを選択すると、ソースはファイル名ではなく絶対パスを必要とするため、ソースは動作しません。したがって、これはわかりませんが、これがどのようにデフォルトとして役立つかはわかりません。 )

回避策:
1.書き込み〜/明示 - 私はかなり頻繁に新しいシェルにSSHと私は$HOMEにいるかどうかについて考えずにナビゲーション開始する必要があるため、これは、私は避けたいものですかない。
2. compinitを使用しないでください。私は基本的にコンテキスト認識の完了が好きです。私はそれを自分のニーズに合わせたいと思っています。

答えて

0

bashで次の作品、

人ソース -

source filename [arguments] 
       Read and execute commands from filename in the current shell environment and return the exit status of the last command executed from filename. If filename does not contain a slash, file 
       names in PATH are used to find the directory containing filename. The file searched for in PATH need not be executable. When bash is not in posix mode, the current directory is searched if 
       no file is found in PATH. If the sourcepath option to the shopt builtin command is turned off, the PATH is not searched. 

フラグ命令がソースパスの説明少し上である無効にする

 shopt [-pqsu] [-o] [optname ...] 
       Toggle the values of variables controlling optional shell behavior. With no options, or with the -p option, a list of all settable options is displayed, with an indication of 
       whether or not each is set. The -p option causes output to be displayed in a form that may be reused as input. Other options have the following meanings: 
       -s  Enable (set) each optname. 
       -u  Disable (unset) each optname. 
       -q  Suppresses normal output (quiet mode); the return status indicates whether the optname is set or unset. If multiple optname arguments are given with -q, the return 
        status is zero if all optnames are enabled; non-zero otherwise. 
       -o  Restricts the values of optname to be those defined for the -o option to the set builtin. 
... 
      sourcepath 
         If set, the source (.) builtin uses the value of PATH to find the directory containing the file supplied as an argument. This option is enabled by default. 

ように実行削除する必要があり、以下のタブの完成からパス...

shopt -u sourcepath

+0

ありがとうございます。しかし、私がこれをすると、 'shopt'コマンドが見つからなかったと言います。 – skaphle

+0

私の答えはbashのために働いています。私はzshの組み込み関数についても調べ始めました。そして、それはちょっとした痛みであると思われます。つまり、zshoptionsとzshbuiltinsです。 setoptは興味のあるコマンドのようで、HASH_LIST_ALLオプションかもしれませんが、私はまだそれを証明していません。 –

関連する問題