跳转至内容

Shell 套件指南

来自 ArchWiki
Arch 软件包指南

32-bitCLRCMakeCrossDKMSEclipseElectronFontFree PascalGNOMEGoHaskellJavaKDEKernel modulesLispMesonMinGWNode.jsNonfreeOCamlPerlPHPPythonRRubyRust - SecurityShellVCSWebWine

安装

为了让用户能够更改 shell,shell 必须出现在 /etc/shells 中。大多数 shell 套件都有如下所示的安装脚本

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
}

Shell 补全

大多数 shell 提供了一组内置的补全,用于少数常用命令,同时也扫描至少一个系统目录以查找可能由其他套件提供的函数。下表总结了套件可以放置补全文件的地方以及文件的命名方式。

Shell Directory 文件
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

其他 Shell

  • Nushell 提供了一些默认补全,但尚不有一个系统级的目录可供提供补全[1]。对于生成 Nushell 补全函数的套件,一种解决方案是将它们打包到 /usr/share/nushell/autoload/binary_name.nu,并使用 post_install() 函数打印一条提示,让用户将 use /path/to/file 语句添加到他们的配置文件中。
提示 一般来说,套件不应拥有对 shell 的 dependsoptdepends 依赖。仅仅因为它们碰巧为 shell 提供了补全,并不意味着套件之间存在依赖关系。例外情况是那些不提供自身补全的套件;补全在默认 shell 套件中不存在,但它们补充集合套件 bash-completionzsh-completions 提供。当这些套件中存在补全文件时,将其添加到 optdepends

Shell 函数或模块

Shell Directory 文件
Elvish /usr/share/elvish/lib/ module_name.elv
Fish /usr/share/fish/vendor_functions.d/ function_name.fish
Zsh /usr/share/zsh/site-functions/ function_name

© . This site is unofficial and not affiliated with Arch Linux.

Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.