brew install zsh zsh-completions
[sudo] chsh -s $(which zsh)
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
~/.zshrc
里的ZSH_THEME="ys"
brew install autojump;git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions;git clone git://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
~/.zshrc
找到plugins=
添加下面的,最后保存执行source ~/.zshrc
plugins=(
autojump
zsh-autosuggestions
zsh-syntax-highlighting
)
复制代码
目前经常使用的 Linux 系统和 OS X 系统的默认 Shell 都是 bash。「oh my zsh」是强化的的 Shell 。html
# Linux
sudo yum install zsh (Fedora和RedHat以及SUSE中)或
sudo apt-get install zsh (Debian系列,Ubuntu )
# macOS 系统自带了zsh, 通常不是最新版,若是须要最新版可经过Homebrew来安装(确认安装了Homebrew)
brew install zsh zsh-completions
# 或者也可使用MacPorts(包管理工具)
sudo port install zsh zsh-completions
复制代码
# 把zsh设为默认shell,若是shell列表中没有zsh或者你没有使用chsh权限的时候,不起做用
echo $SHELL
[sudo] chsh -s $(which zsh) 或 chsh -s /bin/zsh
复制代码
# 安装 oh my zsh 以前必须安装 zsh,不然会收到以下提示:Zsh is not installed! Please install zsh first!
# 方法一:官网上的方法,但须要安装wget或者curl。wget,用来从指定的 URL 下载文件。curl,发出网络请求,而后获得和提取数据。
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# 方法二:固然也能够经过git下载 ,我以为git最亲切 哈哈哈哈
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
复制代码
# Oh-My-Zsh 的默认配置文件在:~/.zshrc。编辑~/.zshrc 修改主题,这里我用的是 ys 主题,更多主体看[这里](https://github.com/robbyrussell/oh-my-zsh/wiki/Themes),直接修改便可,无需下载
ZSH_THEME="ys"
# !!!! 重启终端后有效 或 使用 source ~/.zshrc 更新配置
# 题外话,不太想显示主机名,因此直接干掉主机名
# 编辑 ~/.oh-my-zsh/themes/ys.zsh-theme,最后面改为这样
PROMPT=" %{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \ %(#,%{$bg[yellow]%}%{$fg[black]%}%n%{$reset_color%},%{$fg[cyan]%}%n) \ %{$fg[white]%}in \ %{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\ ${hg_info}\ ${git_info}\ \ %{$fg[white]%}[%*] $exit_code %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"
复制代码
插件依然须要打开~/.zshrc
,找到plugins=
,而后在里面写须要的插件名,有些插件可能还须要安装。 !!!! 注意,只要改了此文件,重启终端后有效 或 使用 source ~/.zshrc
更新配置。linux
这边插件推荐 : autojump、zsh-autosuggestion 以及 zsh-syntax-highlighting。git
功能:实现目录间快速跳转,想去哪一个目录直接 j + 目录名
,不用在频繁的 cd 了! github地址。github
history | grep "git clone"
这个命令就能找到近期 clone 了哪些库,省却了写一堆代码的功夫。shell
autojump
就是经过记录你在 history
中的行为把你访问过的文件夹路径都 cache 下来,当你输入路径名的时候会模糊匹配你以前cd
过的目录路径,配合后面的自动提示插件,无敌了!!!vim
以下图,我先cd
到一些目录,而后就能够j
快速切换,用jo
快递在finder里打开文件夹 bash
# 安装步骤
# ------ mac -------
brew install autojump
vim ~/.zshrc
# 在文件里找到plugins,添加
plugins=(autojump)
# 在文件末尾添加
[[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh
source $ZSH/oh-my-zsh.sh
# 最后
source ~/.zshrc
# ------ linux -----
git clone git://github.com/joelthelion/autojump.git
cd autojump
./install.py
vim ~/.zshrc
# 在文件里找到plugins,添加
plugins=(autojump)
# 在文件末尾添加
[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh
source ~/.zshrc
复制代码
如图所示,输入命令时可提示自动补全(灰色部分),而后按键盘 → (!!!!上下左右的右键,不是tab键)便可补全 markdown
# 安装
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
vim ~/.zshrc
# 在文件里找到plugins,添加
plugins=(
autojump
zsh-autosuggestions
)
source ~/.zshrc
复制代码
平常用的命令会高亮显示,命令错误显示红色 网络
# 安装
git clone git://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
vim ~/.zshrc
# 在文件里找到plugins,添加
plugins=(
autojump
zsh-autosuggestions
zsh-syntax-highlighting
)
source ~/.zshrc
复制代码
# mac安装
brew install asciinema
# 开始记录 first-rec.cast是自定义的文件名 也能够没有文件名
asciinema rec first-rec.cast
# 中止记录
exit
# 按Enter键,而后 访问出现的 url
# ctrl + c 会存到本地,asciinema upload first-rec.cast 能够再次上传到官网
# 登陆
asciinema auth
# 首次注册会去官网,而后写个邮箱,邮箱会受到邮件,点击连接即注册
# 以后,通常会向邮箱里发送登陆验证,点击便可
# 而后就会将你录制的视频,存在你的帐号下
复制代码
让录制的命令视频显示curl
<a href="https://asciinema.org/a/14?autoplay=1"><img src="https://asciinema.org/a/14.png" width="836"/></a>
复制代码
[](https://asciinema.org/a/14)
复制代码