0%

zsh、Oh-My-Zsh及相关设置

注:本文主要参考该文章

1 安装并设置zsh

安装命令:

1
sudo apt install zsh

设置zsh为默认shell:

1
chsh -s $(which zsh)

2 安装Oh My Zsh

安装命令:

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

3 安装主题PowerLevel10k

安装命令:

1
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k

进入.zshrc设置主题:

1
ZSH_THEME="powerlevel10k/powerlevel10k"

4 安装插件

4.1 日常插件

zsh-autosuggestions:

1
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

zsh-syntax-highlighting:

1
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

设置要启动的插件(Plugins):

1
2
3
4
5
6
7
8
9
plugins=(
git
zsh-autosuggestions
zsh-syntax-highlighting
extract
sudo
tmux

)

值得注意的是,除了zsh-autosuggestions 与zsh-syntax-highlighting 需要单独安装外,上述的其他插件均是内嵌的,可直接添加至配置文件中直接使用。

4.2 Tmux设置

该部分主要参考文章

安装命令:

1
sudo apt-get install tmux

tmux 的个性化设置需在主目录编辑.tmux.conf 文件,本人的文件设置如下:

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
set -g prefix C-z
unbind C-b
bind C-a send-prefix

bind r source-file ~/.tmux.conf \; display-message "Config reloaded.."

unbind '"'
bind - splitw -v -c '#{pane_current_path}'
unbind %
bind | splitw -h -c '#{pane_current_path}'

set-option -g mouse on

set -g base-index 0
set -g pane-base-index 0

# setw -g utf8 on
set -g status-interval 1
set -g status-justify left
setw -g monitor-activity on

set -g status-bg black
set -g status-fg yellow
set -g status-left "#[bg=#FF661D] ❐ #S "
set -g status-right "%H:%M:%S %d-%b"
set -g status-left-length 300
set -g status-right-length 500
set -wg window-status-current-format " #I:#W#F "

set -g message-style "bg=#202529, fg=#91A8BA"

set -g default-terminal "screen-256color"

其他使用说明可参考上述链接。在oh my zsh 插件中添加了 tmux 后,可以使用如下快捷键:

hotkey