安装
1、下载: 点击这里去官网下载。
2、设为默认终端
3、选择配色: 一般都是选
Solarized Dark
。设置路径为偏好设置
-> Profiles
-> Colors
。
配置
1、修改 iTerm 主题
-
a. 安装
oh-my-zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
如果 shell 没有切换,执行命令:
chsh -s /bin/zsh
注意:如果使用了 zsh,终端启动时 ~/.bash_profile 将不会被加载,解决办法:修改 ~/.zshrc文件,在其中添加:source ~/.bash_profile
-
b. 主题为
agnoster
执行vim ~/.zshrc
,将shell主题修改为agnoster
ZSH_THEME="agnoster"
注意:安装完成后会遇到箭头是乱码,这是因为缺少
Powerline
字体,使用git下载powerline;git clone https://github.com/powerline/powerline.git
然后将git资源下的
PowerlineSymbols.otf
移动到~/资源库/Fonts
下,并更新系统字体即可。然后,设置在 iTerm 偏好里设置如下:
2、自动补全git命令
克隆仓库到本地 ~/.oh-my-zsh/custom/plugins
路径下:
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
执行 vim ~/.zshrc
,找到插件设置命令,默认是 plugins=(git)
,需要修改为:
plugins=(zsh-autosuggestions)
3、语法高亮
下载插件:
brew install zsh-syntax-highlighting
配置 ~/.zshrc
文件,插入一行,
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
保存:
source ~/.zshrc
4、隐藏主机名
配置 ~/.zshrc
文件,插入一行,
DEFAULT_USER="LynnZhang" #注意LynnZhang是我的主机名,可以通过命令`whoami`查看
5、autojump
brew install autojump
在 .zshrc
中找到 plugins=
,在后面添加
plugins=(autojump)
[[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh
source ~/.zshrc
使用:
history | grep "git clone"
查看输入的历史记录
手动添加一个目录:
autojump -a [目录]
如果你突然想要把当前目录变成你的最爱和使用最频繁的文件夹,你可以在该目录通过命令的参数 i 来手工增加它的权重,这将使得该目录更可能被选择跳转。
autojump -i 权重数值
相反的例子是在该目录使用参数 d 来减少权重
autojump -d 权重数值
要跟踪所有这些改变,这会显示数据库中的统计数据。输入:
autojump -s
而以下命令将会把不再存在的目录从数据库中移除。
autojump --purge
拓展
作用 | 快捷键 |
---|---|
新建标签 | command + t |
关闭标签 | command + w |
切换标签 | command + 数字 command + 左右方向键 |
切换全屏 | command + enter |
查找 | command + f |
垂直分屏 | command + d |
水平分屏 | command + shift + d |
切换屏幕 | command + option + 方向键 command + [ 或 command + ] |
查看历史命令 | command + ; |
查看剪贴板历史 | command + shift + h |
清除当前行 | ctrl + u |
到行首 | ctrl + a |
到行尾 | ctrl + e |
前进后退 | ctrl + f/b (相当于左右方向键) |
上一条命令 | ctrl + p |
搜索命令历史 | ctrl + r |
删除当前光标的字符 | ctrl + d |
删除光标之前的字符 | ctrl + h |
删除光标之前的单词 | ctrl + w |
删除到文本末尾 | ctrl + k |
交换光标处文本 | ctrl + t |
清屏1 | command + r |
清屏2 | ctrl + l |
其他
安装Homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
安装ruby:
brew install ruby
网友评论