📅  最后修改于: 2023-12-03 14:44:32.928000             🧑  作者: Mango
本文将介绍如何配置zsh的命令行界面,并展示如何定制zsh的外观。
sudo apt-get install zsh # Ubuntu
brew install zsh # macOS
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
通过修改主题,你可以改变zsh的外观。
oh-my-zsh自带了一些主题,你可以使用ls ~/.oh-my-zsh/themes
查看列表:
af-magic.zsh-theme gnzh.zsh-theme robbyrussell.zsh-theme ys.zsh-theme
af-magic2.zsh-theme jj.zsh-theme risto.zsh-theme
alanpeabody.zsh-theme kafeitu.zsh-theme rkj-repos.zsh-theme
amuse.zsh-theme kardan.zsh-theme romkatv.zsh-theme
apple.zsh-theme lambda.zsh-theme s1n.zsh-theme
aristotle.zsh-theme liangjian-zsh-theme simple.zsh-theme
avi.zsh-theme long.zsh-theme sindresorhus.zsh-theme
awesomepanda.zsh-theme lukerandall.zsh-theme sorin.zsh-theme
打开.zshrc
文件,找到ZSH_THEME
变量,将变量的值改为想要的主题名称。例如,要使用robbyrussell
主题,可以这样设置:
ZSH_THEME="robbyrussell"
oh-my-zsh具有许多有用的插件,可以通过启动脚本加载:
plugins=(git bundler osx rake ruby)
oh-my-zsh自带了一些插件,你可以使用ls ~/.oh-my-zsh/plugins
查看列表:
ansible gitfast pyenv
autoenv github rails
battery gitignore rake
bower heroku rbenv
bundler history-substring-search redis-cli
colorize history ruby
common-aliases httpie rvm
cp interrobang screen
debian jira ssh-agent
debian_chroot knife sudo
docker last-working-dir sublime
docker-compose laravel supervisord
encode64 node symfony
extract npm systemd
fabric nvm textmate
fastfile osx themes
fasd pfc tmux
gem pip virtualenv
git-extras python web-search
git-flow-avh rbenv-autoenv bundler
git-flow pythonbrew
=============
sketchup traffic
使用git clone
将插件克隆到~/.oh-my-zsh/plugins
目录。例如,要安装zsh-autosuggestions
插件,可以这样操作:
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/plugins/zsh-autosuggestions
然后,在.zshrc
文件中启用插件:
plugins=(zsh-autosuggestions)
注意:要正确使用插件,请在.zshrc
文件中加载插件之前申明ZSH
环境变量。例如,可以这样设置:
export ZSH=$HOME/.oh-my-zsh
一旦启用插件,你就可以使用它们提供的功能了。例如,zsh-autosuggestions
可以自动补全命令的参数:
$ git commi # 输入命令之后,按下向上箭头可以看到自动补全的建议
以上就是zsh基础配置、主题和插件的介绍。为了更好地使用zsh,你可以花费一定的时间来优化配置,以满足自己的需要。