iterm2 配置总结 主题配置

目录

  • 教程
  • iterm2 配色方案
  • iterm2 主题配置
  • 自动连接服务器配置
    • expect脚本配置
    • 自动登录服务器脚本
    • 普通服务器脚本
    • 跳板机脚本
  • iTerm2 profile配置

教程

基于iterm2的Mac终端美化指南

iterm2 配色方案

  1. 首先下载 iTerm 2
  2. 打开iTerm 2
  3. 输入下面指令安装oh-my-zsh
    curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh

cd ~
vi .zshrc

修改:ZSH_THEME=“robbyrussell” 为 ZSH_THEME=“cloud”

iterm2 主题配置

自定义iTerm2主题配置(iTerm2-Color-Schemes)
推荐主题:
Dark Background
Smoooooth
Tango Dark
Builtin Dark
Buloco Dark
Builtin Tango Dark
Calamity
ChallengerDeep
Chester
Cobalt2
Dark Pastel
Dracula
Encom
Espreeso Libre
Hipster Green
Homebrew
Jellybeans
JetBrains Dracula
MaterialDark
NightLion v2
Nocturnal Winter
Solarized Dark Higher Contrast

自动连接服务器配置

expect脚本配置

expect这个语言,我觉得提供了和进程交互的能力吧,具体语句含义见参考。
下面有2种情况,第一种是直接连服务器,也就是需要输入密码的方式,当然在服务器把你电脑公钥放上去,密码也不用输了。第二种情况的话,大部分公司去连线上服务器,都要经过跳板机,我们公司使用的是JumpServer,跳板机如何配置也不讲了。

自动登录服务器脚本

iTerm2创建ssh自动登陆脚本

普通服务器脚本

connect.sh

#!/usr/bin/expect
set timeout 30
spawn ssh  [lindex $argv 0]@[lindex $argv 1]
expect "password"
send "[lindex $argv 2]\r\n"
expect "$*"
send "cd [lindex $argv 3]/\n"
send "tail -200f [lindex $argv 4]\n"
interact

直接使用方式如下

./connect.sh {username} {host} {password} {directory}  {logFile}

跳板机脚本

jump.sh

#!/usr/bin/expect
spawn ssh jhost
expect "*" {send "[lindex $argv 0]\n"} 
expect "$*" {send "cd [lindex $argv 1] \n"}
send "tail -200f [lindex $argv 2]\n"
interact

直接使用方式如下

./jump.sh {jumpServerName} {directory}  {logFile}

iTerm2 profile配置

在iTerm2中每个profile对应于一台远程主机。

profile的配置页面如下
在这里插入图片描述

tags用于对profile分组,我们可以一键打开同一tag下的所有服务器。
Badge用于给打开的profile增加一个标记,在控制台右上角显示。
Command中的命令/脚本会在profile打开时执行,上一节的脚本会配置在这里。

profile使用方式如下

在这里插入图片描述

我们可以打开具体某个profile也可以通过Open All打开某个tag下所有profile
在这里插入图片描述

一秒钟查看6台服务器错误日志,是不是省了很多力气。

如何简易配置多个profile
有些profile的配置十分复杂(比如文件上传下载,每个profile都要重新配置),我们不可能手动配置第二个,我们有以下方式快速来配置其他类似的profile。

使用 Other Actions -> Duplicate Profile
使用 Other Actions -> Save Profile as JSON导出配置,然后修改为新配置,在通过 Other Actions -> Import JSON Profiles 导入
使用Dynamic Profile功能,和普通的profile不同,Dynamic Profile相当于做了持久化,并且修改后配置立刻生效。
Dynamic Profile 文件格式和导出的profile一致,只不过需要放在一个固定目录下,具体如何使用见参考中的链接


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部