Oh my zsh & iterm2
Oh My Zsh is a delightful, open source, community-driven framework for managing your Zsh configuration. It comes bundled with thousands of helpful functions, helpers, plugins, themes, and a few things that make you shout…
iTerm2 is a replacement for Terminal and the successor to iTerm. It works on Macs with macOS 10.14 or newer. iTerm2 brings the terminal into the modern age with features you never knew you always wanted.
1 安装 oh my zsh
1.1 安装方法 1
# 下载oh my zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# 改变位置
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
如果报错:curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
,有两种解决办法:
- 将 DNS 设置为:
8.8.8.8
或者114.114.114.114
(参考文章:https://blog.csdn.net/bryong/article/details/108374261 - 使用安装方法 2
1.2 安装方法 2
2 基本配置
2.1 修改主题
- 主题文件位置:/Users/你的用户名/.oh-my-zsh/themes
- 主题样式:https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
# 下载主题
/Users/daxiong/.oh-my-zsh/themes
git clone https://github.com/bhilburn/powerlevel9k.git
vim ~/.zshrc
# 修改
ZSH_THEME="agnoster"
2.2 终端命令高亮和补全
cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ## 下载高亮
git clone https://github.com/zsh-users/zsh-autosuggestions
vim ~/.zshrc ## 下载补全
# 修改
plugins=(git
zsh-autosuggestions
zsh-syntax-highlighting)
3 zsh 下的环境变量配置
Mac 的环境变量配置文件如下:
/etc/profile
/etc/paths
~/.bash_profile
~/.bash_login
~/.profile
~/.bashrc
前两个是系统级别的,系统启动就会加载。后面 3 个是当前用户级别的环境变量。后面几个按照从前往后的顺序读取,如果~/.bash_profile
存在,则后面的几个文件就会被忽略不读了,如果不存在,才会依次读取后面的文件。~/.bashrc
没有上述规则,它是 bash shell 打开的时候载入的。
也就是说在当前用户的目录下,如果有了.bash_profile
文件就不会去加载.bashrc
文件。所以如果要能正常加载,需要在.bash_profile
文件的最末尾上加入如下语句:
如果你没有修改过,上面的方法默认重启后就能生效。
但是,现在的 mac 上有些使用 zsh 这个作为默认的,所以在启动 shell 时默认不会按上面的套路去加载。如果想要正常加载.bashrc 文件时,就要找到用户目录下.zshrc 文件加入如下代码:
4 iterm2 远程控制
4.1 方法一
4.2 方法二
创建 shell 脚本文件:我的文件路径:/Users/kuma/hadoop_cluster/login.sh
注意:要赋予文件执行权限:chmod +x /Users/kuma/hadoop_cluster/login.sh
4.3 配置 iterm2
Send text at start 的格式:脚本路径+端口号+服务器用户名+hostname+密码
例如:/Users/kuma/hadoop_cluster/login.sh 22 yowai slave1 00000000