Zsh 可以让使用者利用配置客制各种不同的功能,像是命令的自动补全、提示、高亮与缩写等。但是要自己设定这些需要花费大量的时间,因此找一个好的框架,并且使用大家公认的大众配置会是个比较省力的方式。
这些框架除了预配置的功能外,都会提供扩充的插件,藉由引入这些插件,我们可以轻松地实现各式功能,而不需要自己去做大量的配置。
Zim 是个 Zsh 配置框架,它提供了丰富的预设功能,并且以高效着称。
除了预设的功能外,使用者还可以使用 Modules 对功能进行扩充,并选择自己喜爱的 Themes 来使用。
使用 Curl 安装 Zim :
curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh
安装完成後,重新启动终端机,就可以开始使用 Zim 所提供的各式功能了。
Zim 的配置藉由一个配置档 ~/.zimrc
来处理,安装完成後他会有预设的配置,使用者可以自己决定是否要使用这些配置。
Zim 的 Module 与 Theme 的安装方式是相同的, 接着以 theme eriner
为例,展示如何配置 Zim 。
首先,在 ~/.zimrc
中将 eriner
加入到配置:
# Zim theme
zmodule eriner
储存後,使用指令安装 Module :
zimfw install
重启终端後就可以看到新的主题效果了。
使用指令更新所有在 ~/.zimrc
中的 Module :
zimfw update
先将要删除的 Module 从 ~/.zimrc
中删去:
# Zim theme
#zmodule eriner
然後使用指令解安装 Module :
zimfw uninstall
它会询问是否要删除,选择是後,就会开始进行解安装的动作。
Zim 在安装时会预设配置多个不同的 Module ,其列表如下:
# Start configuration added by Zim install {{{
# -------
# Modules
# -------
# Sets sane Zsh built-in environment options.
zmodule environment
# Provides handy git aliases and functions.
zmodule git
# Applies correct bindkeys for input events.
zmodule input
# Sets a custom terminal title.
zmodule termtitle
# Utility aliases and functions. Adds colour to ls, grep and less.
zmodule utility
#
# Prompt
#
# Exposes to prompts how long the last command took to execute, used by asciiship.
zmodule duration-info
# Exposes git repository status information to prompts, used by asciiship.
zmodule git-info
# A heavily reduced, ASCII-only version of the Spaceship and Starship prompts.
zmodule asciiship
# Additional completion definitions for Zsh.
zmodule zsh-users/zsh-completions
# Enables and configures smart and extensive tab completion.
# completion must be sourced after zsh-users/zsh-completions
zmodule completion
# Fish-like autosuggestions for Zsh.
zmodule zsh-users/zsh-autosuggestions
# Fish-like syntax highlighting for Zsh.
# zsh-users/zsh-syntax-highlighting must be sourced after completion
zmodule zsh-users/zsh-syntax-highlighting
# Fish-like history search (up arrow) for Zsh.
# zsh-users/zsh-history-substring-search must be sourced after zsh-users/zsh-syntax-highlighting
zmodule zsh-users/zsh-history-substring-search
# }}} End configuration added by Zim install
接着说明几个主要的 Module 所带来的功能是什麽。
此为官方的 Module ,作用为设定合理的 Zsh 的选项。
关於 Zsh 的选项可以参考 Moving to zsh, part 3: Shell Options 。
此为官方的 Module ,设定 Git 相关的别名与功能。
此为官方的 Module ,设定 ls
、 grep
与 less
相关的配置,包含高亮与别名。
此为官方的 Module ,纪录指令执行的时间。
此为官方的 Module ,导出 Git 库相关的资讯。
此为官方的 Theme ,使用 git-info
与 duration-info
显示相关的讯息。
此为官方的 Module ,提供指令的相关提示,需要搭配 zsh-users/zsh-completions
来提供指令的资讯补完。
zsh-autosuggestions
会记忆使用者之前的指令,然後再输入相似的指令时对使用者做提示,如果确认之後,可以使用右箭头按钮完成输入。
zsh-syntax-highlighting
提供 Zsh 指令高亮的显示。
zsh-history-substring-search
让使用者可以输入指令的一部分,然後使用上下方向键选取之前与现在所输入的字串有吻合的指令。
Zim 提供了许多的 Modules 与 Themes ,可以依照需求做安装,像是 homebrew 提供了 brew
指令的别名。
另外也有许多第三方的套件也可以使用 Zim 来管理,只要是使用 {init.zsh,module_name.{zsh,plugin.zsh,zsh-theme,sh}}
的档案安装的套件都可以,如果不是的话,也可以使用 zmodule --source
指定安装的档案。
这些第三方套件,像是 Spaceship 、 alias-tips 等,都可以藉由 awesome-zsh-plugins 寻找。
zimfw
与 zmodule
。zimfw
可以安装、更新与解安装於 ~/.zimrc
设定的套件( Modules )。zmodule
在 ~/.zimrc
中设定各种想要载入的套件。
终於来到第二个练习了! 练习范例:https://www.sixvfx.com/northern_l...
教完基本的建立字典、查询以及更改元素,今天就要更进阶一点,会教到几个专属於字典的方法呦~像是keys...
随着科技进步与智能设备的普及,越来越多人使用智能手机或者手提电脑搜寻网络上的资料。2019年Goog...
续 Day 21 协调服务 (Coordination Services) 像 Apache Zo...
前言 本章节,延续上一章节有关於SSH连线的介绍,继续介绍SSH之以金钥为基础的验证与设定介绍。 产...