被命令行自动补齐功能吸引,在编辑指令的时候,对于之前使用过的指令,按→即可快速补全。
下文详细讲述如何搭建环境及安装插件,以及存在防火墙的情况下如何手动安装操作。
cat /etc/shells
输出:
/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
- chsh -s /bin/bash
-
- chsh -s /bin/zsh
sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"
参考的是以下网址,亲测mac上安装无误,安装好后终端就变彩色了
wget、curl一把安装好固然好,但在办公网络下,由于防火墙的存在或其他限制,可能需要手动下载,手动安装,这就比较头痛了,需要手动下载2个组件,修改安装sh文件,再手动执行。
1.下载install.sh文件
https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
2.下载oh my zsh 代码库
3.vim install.sh
由于公司防火墙等原因,直接执行sh文件clone oh my zsh 代码库会报错"Error: git clone of oh-my-zsh repo failed"
修改clone部分为 cp本地已下载的文件,相关代码在Manual clone with git config options to support git < v1.7.2处
修改为:
- # Manual clone with git config options to support git < v1.7.2
- git init --quiet "$ZSH" && cd "$ZSH" \
- && git config core.eol lf \
- && git config core.autocrlf false \
- && git config fsck.zeroPaddedFilemode ignore \
- && git config fetch.fsck.zeroPaddedFilemode ignore \
- && git config receive.fsck.zeroPaddedFilemode ignore \
- && git config oh-my-zsh.remote origin \
- && git config oh-my-zsh.branch "$BRANCH" \
- # && git remote add origin "$REMOTE" \
- # && git fetch --depth=1 origin \
- # && git checkout -b "$BRANCH" "origin/$BRANCH" || {
- # [ ! -d "$ZSH" ] || {
- # cd -
- # rm -rf "$ZSH" 2>/dev/null
- # }
- # fmt_error "git clone of oh-my-zsh repo failed"
- # exit 1
- # }
- # Exit installation directory
- cp -R /Users/myname/Downloads/ohmyzsh_install/ohmyzsh-master/* /Users/myname/.oh-my-zsh
- cd -
- #
- echo
- }
4.执行安装
./install.sh
vim ~/.zshrc
查看主题 ZSH_THEME
查看插件plugins
zsh-syntax-highlighting 高亮插件,可用于检查命令是否输入正确
zsh-autosuggestions 自动补全插件,可记住过往命令
1.修改配置
vim ~/.zshrc
修改为plugins=(git zsh-syntax-highlighting zsh-autosuggestions)
2.安装插件
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
如不能git clone,手动下载后mv到对应路径下
~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
3.更新配置,使之立刻起效
source ~/.zshrc
参考oh-my-zsh 国内安装及配置_菜饼同学的博客-CSDN博客_ohmyzsh国内
incr 目录提示和补全插件
下载插件
wget http://mimosa-pudica.net/src/incr-0.2.zsh
将第三方插件放在插件目录库路径下
- mkdir ~/.oh-my-zsh/plugins/incr
- cd ~/.oh-my-zsh/plugins/incr
- mv /Users/XXX/incr-0.2.zsh ./
-
-
- vim ~/.zshrc
- # 末尾加上 source ~/.oh-my-zsh/plugins/incr/incr*.zsh
-
- # 更新配置
- source ~/.zshrc