iTerm2

记录下iTerm2 的各种使用。

Color Schemes

列表: https://github.com/mbadolato/iTerm2-Color-Schemes

下载该库,导入。

Via iTerm preferences

  • Launch iTerm 2. Get the latest version at iterm2.com
  • Click on iTerm2 menu title
  • Select Preferences… option
  • Select Profiles
  • Navigate to Colors tab
  • Click on Color Presets
  • Click on Import
  • Select the .itermcolors file(s) of the schemes you’d like to use
  • Click on Color Presets and choose a color scheme

我选中了,Brogreammer。

安裝 powerline font

Doc

通过git直接安装:

Github page

1
2
3
$ git clone git@github.com:powerline/fonts.git
$ cd fonts
$ ./install.sh

最后在iTerm中修改字体。

Preferences > Profiles > Text > Change Font

我选中了,Meslo LG S DZ字体。

安裝 zsh

1
$ brew install zsh

设置为默认shell:

1
2
$ sudo sh -c "echo $(which zsh) >> /etc/shells" 
chsh -s $(which zsh)

安装 oh-my-zsh

1
$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

ZSH配置文件

~/.zshrc

改过所有配置,需要生效:

1
exec $SHELL
  • 修改主题

    主题列表:https://github.com/robbyrussell/oh-my-zsh/wiki/Themes

    改为我喜欢的随机:

    //将zsh主题修改为“agnoster”

    ZSH_THEME=”agnoster”

    //Or随机

    ZSH_THEME=random

  • 主题:powerlevel9k

    1
    $ git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k

    或将库下载后放入:~/.oh-my-zsh/custom/themes/

    左右显示路径、时间等提示。

    ZSH_THEME=”powerlevel9k/powerlevel9k”

    # command line 左边显示的內容(路径)

    POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir vcs dir_writable status)

    # command line 右边显示的內容(时间)

    POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(time)

    上面显示的信息,可参考

  • 插件

    插件列表:https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins

    查看插件路径:ls ~/.oh-my-zsh/plugins,然后在配置文件中配置。

    1
    plugins=(git-extras git mvn svn osx sudo ruby brew brew-cask npm colored-man colorize copydir history sublime command-not-found zsh-syntax-highlighting z web-search bundler wd)

快捷键

  • ⌘ + Click:可以打开文件,文件夹和链接
  • ⌘ + n:新建窗口
  • ⌘ + t:新建标签页
  • ⌘ + w:关闭当前页
  • ⌘ + 数字 & ⌘ + 方向键:切换标签页
  • ⌥⌘ + 数字:切换窗口
  • ⌘ + enter:切换全屏
  • ⌘ + d:左右分屏
  • ⇧⌘ + d:上下分屏
  • ⌘ + ;:自动补全历史记录
  • ⇧⌘ + h:自动补全剪贴板历史
  • ⌥⌘ + e:查找所有来定位某个标签页
  • ⌘ + r & ⌃ + l:清屏
  • ⌘ + /:显示光标位置
  • ⌥⌘ + b:历史回放
  • ⌘ + f:查找,然后用 tab⇧ + tab 可以向右和向左补全,补全之后的内容会被自动复制,
    还可以用 ⌥ + enter 将查找结果输入终端
  • 选中即复制,鼠标中键粘贴

很多快捷键都是通用的,和 Emace 等都是一样的

  • ⌃ + u:清空当前行
  • ⌃ + a:移动到行首
  • ⌃ + e:移动到行尾
  • ⌃ + f:向前移动
  • ⌃ + b:向后移动
  • ⌃ + p:上一条命令
  • ⌃ + n:下一条命令
  • ⌃ + r:搜索历史命令
  • ⌃ + y:召回最近用命令删除的文字
  • ⌃ + h:删除光标之前的字符
  • ⌃ + d:删除光标所指的字符
  • ⌃ + w:删除光标之前的单词
  • ⌃ + k:删除从光标到行尾的内容
  • ⌃ + t:交换光标和之前的字符

Help

.zshrc配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH=/Users/wenghengcong/.oh-my-zsh

# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
#ZSH_THEME="robbyrussell"
# 主题设置
# 主题列表在 ~/.oh-my-zsh/themes/
# 如果设置为 "random"(不加引号), 每次开启都会是不同的主题,其他主题注意加引号
# ZSH_THEME="ys"
#ZSH_THEME=random
ZSH_THEME="powerlevel9k/powerlevel9k"
# command line 左边显示的內容(路径)
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir vcs dir_writable status)
# command line 右边显示的內容(时间)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(time)


# Uncomment the following line to use case-sensitive completion.
# 如果想要大小写敏感,可以取消注释下面的一行
# CASE_SENSITIVE="true"

# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# 如果想要连接符不敏感,可以取消注释下面的一行。_ 和 - 将可以互换
HYPHEN_INSENSITIVE="true"

# Uncomment the following line to disable bi-weekly auto-update checks.
# 如果不想要自动更新,可以取消注释下面的一行
# DISABLE_AUTO_UPDATE="true"

# Uncomment the following line to change how often to auto-update (in days).
export UPDATE_ZSH_DAYS=7

# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"

# Uncomment the following line to disable auto-setting terminal title.
# 是否禁止更改终端标题,不要禁止,不然所有终端tab只显示zsh了,而不随着目录的改变而改变显示
# DISABLE_AUTO_TITLE="true"

# Uncomment the following line to enable command auto-correction.
# 自动纠正命令,不启用,不怎么好用
# ENABLE_CORRECTION="true"

# Uncomment the following line to display red dots whilst waiting for completion.
# 按tab键补全命令的时候,如果没什么可补全的就会出现三个红点,更人性化显示,这里我们启用
COMPLETION_WAITING_DOTS="true"

# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"

# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# 历史命令日期显示格式
# 有三种方式: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"

# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder

# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
UNBUNDLED_COMMANDS=(foreman spin)
plugins=(git npm osx ruby sudo wd bundler zsh-syntax-highlighting web-search z)

source $ZSH/oh-my-zsh.sh

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
alias cls='clear'
alias ll='ls -l'
alias la='ls -a'
alias grep="grep --color=auto"
#alias -s html='vim' # 在命令行直接输入后缀为 html 的文件名,会在 Vim 中打开
#alias -s rb='vim' # 在命令行直接输入 ruby 文件,会在 Vim 中打开
#alias -s py='vim' # 在命令行直接输入 python 文件,会用 vim 中打开,以下类似
#alias -s js='vim'
#alias -s c='vim'
#alias -s java='vim'
#alias -s txt='vim'
#alias -s gz='tar -xzvf' # 在命令行直接输入后缀为 gz 的文件名,会自动解压打开
#alias -s tgz='tar -xzvf'
#alias -s zip='unzip'
#alias -s bz2='tar -xjvf'

其他配置

无限滚屏

有些命令,显示列表过长,会截断。

屏幕快照 2018-09-11 上午11.19.17