「シェルパッケージガイドライン」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(→‎Install: 翻訳)
25行目: 25行目:
 
}}
 
}}
   
  +
== シェルの補完機能 ==
== Shell completions ==
 
   
  +
ほとんどのシェルは、いくつかの一般的なコマンドの補完セットを内蔵しており、同時に他のパッケージによって提供されるかもしれない関数のために少なくとも1つのシステムディレクトリをスキャンします。次の表は、パッケージが補完ファイルを置く場所と、そのファイル名をまとめたものです。
Most shells provide a built in set of completions for a few common commands while also scanning at least one system directory for functions that may be supplied by other packages. The following table is a summary of where packages may place completion files and what the files should be named.
 
   
 
{| class="wikitable"
 
{| class="wikitable"
! Shell !! Directory !! File
+
! シェル !! ディレクトリ !! ファイル
 
|-
 
|-
 
| [[Bash]] || {{ic|/usr/share/bash-completion/completions}} || {{ic|''binary_name''}}
 
| [[Bash]] || {{ic|/usr/share/bash-completion/completions}} || {{ic|''binary_name''}}
39行目: 39行目:
 
|}
 
|}
   
  +
その他のシェル
Other shells:
 
   
* [[Elvish]] provides some default completions, but does ''not'' have a system-wide directory where completions can be provided yet[https://github.com/elves/elvish/issues/1004]. For packages that generate Elvish shell completion functions, one solution would be to package them {{ic|/usr/share/elvish/completions/''binary_name''.elv}} and use a {{ic|post_install()}} function to print a tip for users to symlink it to their {{ic|$XDG_CONFIG_HOME/elvish/lib/}} directory.
+
* [[コマンドラインシェル#代替シェル|Elvish]] はいくつかのデフォルトの補完を提供しますが、補完を提供するシステム全体のディレクトリはまだ [[https://github.com/elves/elvish/issues/1004] ありません。Elvish シェル補完関数を生成するパッケージの場合、一つの解決策は {{ic|/usr/share/elvish/completions/''binary_name''.elv}} をパッケージ化して {{ic|post_install()}} 関数を使用して、ユーザーが {{ic|$XDG_CONFIG_HOME/elvish/lib/}} ディレクトリにシンボリックリンクできるように tip を表示することでしょう。
   
  +
{{Tip|一般的なルールとして、パッケージはシェルに ''depend'' や ''optdepends'' を持つべきではありません。たまたまそのための補完を提供したからといって、パッケージの依存関係を示唆するものではありません。補完機能はデフォルトのシェルパッケージには存在しませんが、補足の収集パッケージ {{Pkg|bash-completion}} や {{Pkg|zsh-completions}} によって ''提供'' されます。これらのパッケージに補完ファイルが存在する場合、それらを {{ic|optdepends}} に追加してください。}}
{{Tip|As a general rule, packages should have neither ''depends'' nor ''optdepends'' on shells. Just because they happen to supply completions for them does not imply a package dependency relationship any way. The exception is packages that do not supply their own completions; the completions do not exist in the default shell package, but they ''are provided'' by the supplemental collection packages {{Pkg|bash-completion}} or {{Pkg|zsh-completions}}. When completion files exist in these packages, add them to {{ic|optdepends}}.}}
 

2022年2月22日 (火) 22:44時点における版

関連記事

インストール方法

ユーザが シェルの変更 を行うには、シェルを /etc/shells に記述する必要があります。ほとんどのシェルパッケージには以下のようなインストールスクリプトがあります。

shellname.install
post_install() {
    grep -Fqx /bin/shellname /etc/shells || echo /bin/shellname >>/etc/shells
    grep -Fqx /usr/bin/shellname /etc/shells || echo /usr/bin/shellname >>/etc/shells
}

post_upgrade() {
    post_install
}

post_remove() {
    sed -i -r '/^(\/usr)?\/bin\/shellname$/d' etc/shells
}

シェルの補完機能

ほとんどのシェルは、いくつかの一般的なコマンドの補完セットを内蔵しており、同時に他のパッケージによって提供されるかもしれない関数のために少なくとも1つのシステムディレクトリをスキャンします。次の表は、パッケージが補完ファイルを置く場所と、そのファイル名をまとめたものです。

シェル ディレクトリ ファイル
Bash /usr/share/bash-completion/completions binary_name
fish /usr/share/fish/vendor_completions.d binary_name.fish
Zsh /usr/share/zsh/site-functions _binary_name

その他のシェル

  • Elvish はいくつかのデフォルトの補完を提供しますが、補完を提供するシステム全体のディレクトリはまだ [[1] ありません。Elvish シェル補完関数を生成するパッケージの場合、一つの解決策は /usr/share/elvish/completions/binary_name.elv をパッケージ化して post_install() 関数を使用して、ユーザーが $XDG_CONFIG_HOME/elvish/lib/ ディレクトリにシンボリックリンクできるように tip を表示することでしょう。
ヒント: 一般的なルールとして、パッケージはシェルに dependoptdepends を持つべきではありません。たまたまそのための補完を提供したからといって、パッケージの依存関係を示唆するものではありません。補完機能はデフォルトのシェルパッケージには存在しませんが、補足の収集パッケージ bash-completionzsh-completions によって 提供 されます。これらのパッケージに補完ファイルが存在する場合、それらを optdepends に追加してください。