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

提供: ArchWiki
ナビゲーションに移動 検索に移動
(英語版から転載)
 
 
(同じ利用者による、間の3版が非表示)
2行目: 2行目:
 
[[en:Shell package guidelines]]
 
[[en:Shell package guidelines]]
 
{{Related articles start}}
 
{{Related articles start}}
{{Related|Command-line shell}}
+
{{Related|コマンドラインシェル}}
 
{{Related articles end}}
 
{{Related articles end}}
 
{{Package Guidelines}}
 
{{Package Guidelines}}
   
  +
== インストール方法 ==
== Install ==
 
   
  +
ユーザが [[コマンドラインシェル#デフォルトシェルの変更|シェルの変更]] を行うには、シェルを {{ic|/etc/shells}} に記述する必要があります。ほとんどのシェルパッケージには以下のようなインストールスクリプトがあります。
For users to [[Command-line shell#Changing your default shell|change shells]], the shell must appear in {{ic|/etc/shells}}. Most shell packages have install scripts like below:
 
   
 
{{hc|''shellname''.install|
 
{{hc|''shellname''.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''}}
  +
|-
  +
| [[Elvish]] || {{ic|/usr/share/elvish/lib/}} || {{ic|''binary_name''.elv}}
 
|-
 
|-
 
| [[fish]] || {{ic|/usr/share/fish/vendor_completions.d}} || {{ic|''binary_name''.fish}}
 
| [[fish]] || {{ic|/usr/share/fish/vendor_completions.d}} || {{ic|''binary_name''.fish}}
39行目: 41行目:
 
|}
 
|}
   
  +
その他のシェル:
Other shells:
 
   
  +
[[Nushell]] はデフォルトの補完機能をいくつか提供していますが、まだ補完ファイルを提供するためのシステム全体のディレクトリはありません [https://github.com/nushell/nushell/issues/11337] Nushell の補完関数を生成するパッケージの場合、1つの解決策として、{{ic|/usr/share/nushell/autoload/''binary_name''.nu}} にパッケージ化し、{{ic|post_install()}} 関数を使用して、ユーザーに {{ic|use /path/to/file}} ステートメントを設定ファイルに追加するように指示する方法があります。
* [[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.
 
   
  +
{{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}}.}}
 

2025年2月10日 (月) 01:57時点における最新版

関連記事

インストール方法

ユーザが シェルの変更 を行うには、シェルを /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
Elvish /usr/share/elvish/lib/ binary_name.elv
fish /usr/share/fish/vendor_completions.d binary_name.fish
Zsh /usr/share/zsh/site-functions _binary_name

その他のシェル:

Nushell はデフォルトの補完機能をいくつか提供していますが、まだ補完ファイルを提供するためのシステム全体のディレクトリはありません [1] Nushell の補完関数を生成するパッケージの場合、1つの解決策として、/usr/share/nushell/autoload/binary_name.nu にパッケージ化し、post_install() 関数を使用して、ユーザーに use /path/to/file ステートメントを設定ファイルに追加するように指示する方法があります。

ヒント: 一般的なルールとして、パッケージはシェルに dependoptdepends を持つべきではありません。たまたまそのための補完を提供したからといって、パッケージの依存関係を示唆するものではありません。補完機能はデフォルトのシェルパッケージには存在しませんが、補足の収集パッケージ bash-completionzsh-completions によって 提供 されます。これらのパッケージに補完ファイルが存在する場合、それらを optdepends に追加してください。