zsh配置之zshrc

概览:

MacOS 终端zsh配置文件

以下为个人配置

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
# Terminal Colors
# for code in {000..255}; do print -P -- "$code: %F{$code}Color%f"; done
autoload -Uz colors && colors

autoload -Uz vcs_info
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' unstagedstr '%F{red}*' # display this when there are unstaged changes
zstyle ':vcs_info:*' stagedstr '%F{yellow}+' # display this when there are staged changes
zstyle ':vcs_info:*' actionformats \
'%F{5}%F{5}[%F{2}%b%F{3}|%F{1}%a%c%u%F{5}]%f '
zstyle ':vcs_info:*' formats \
'%F{5}%F{5}[%F{2}%b%c%u%F{5}]%f '
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
zstyle ':vcs_info:*' enable git cvs svn

precmd_vcs_info() { vcs_info }
precmd_functions+=( precmd_vcs_info )
setopt prompt_subst
RPROMPT='${vcs_info_msg_0_}'

setopt no_nomatch

PS1="%{%F{255}%}%n%{%f%}@%{%F{039}%}%m%{%f%} %{%F{008}%}exec: %i/%h current: %j%{%f%} %{%F{093}%}status: %(?.%{%F{135}%}[ ok ]%{%f%}.%{%F{196}%}[oops]%{%f%})%{%f%}
%{%F{008}%}%y %1~%{%f%} %{%F{092}%}%#%{%f%}⚑ %{%F{141}%}<<<%{%f%} "

export HISTSIZE=20000000
export SAVEHIST=10000000
setopt BANG_HIST # Treat the '!' character specially during expansion.
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
setopt HIST_VERIFY # Don't execute immediately upon history expansion.

export GPG_TTY=$(tty)

setopt HIST_BEEP

# plugins
autoload -Uz compinit && compinit

source "/Volumes/matrix/configs/zsh/plugins/ohmyzsh/plugins/git/git.plugin.zsh"
source "/Volumes/matrix/configs/zsh/plugins/ohmyzsh/plugins/macos/macos.plugin.zsh"
source "/Volumes/matrix/configs/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh"
source "/Volumes/matrix/configs/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"

# brew
export PATH="/usr/local/sbin:$PATH"

# Go
export GOPROXY=https://goproxy.io,direct
export GOROOT=/Volumes/matrix/Applications/golang/go
export GOPATH=/Volumes/matrix/Applications/golang/res
export PATH=${GOROOT}/bin:${GOPATH}/bin:${PATH}

# Nodejs
export NODE_HOME=/Volumes/matrix/Applications/node/node-v16.13.2-darwin-x64
export PATH=${NODE_HOME}/bin:${PATH}

# jdk
export JAVA_HOME=/Volumes/matrix/Applications/java/jdk1.8.0_221
export JRE_HOME=${JAVA_HOME}/jre
export PATH=${PATH}:${JAVA_HOME}/bin:${JRE_HOME}/bin
export CLASS_PATH=.:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar:${JAVA_HOME}/lib:${JRE_HOME}/lib

# Maven
export PATH=/Volumes/matrix/Applications/java/apache-maven-3.8.4/bin:${PATH}

# ninja
export PATH=/Volumes/matrix/Applications/toolchain/ninja/bin:${PATH}

# qemu
export PATH=/Volumes/matrix/Applications/qemu/bin:${PATH}

# flutter
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=/Volumes/matrix/Applications/flutter/flutter/bin:${PATH}

# ffmpeg
export PATH=/Volumes/matrix/Applications/ffmpeg/bin:${PATH}

## >>> docker remote host
export DOCKER_HOST=ssh://ubuntu@192.168.64.2
export PATH=/Volumes/matrix/Applications/docker/bin:${PATH}

# alias
alias cls='clear'
alias tree='tree -N'
alias git='LANG=en_US git'
alias open_command='open'

# color scheme
## ls
export CLICOLOR=1
export LSCOLORS=Fxexcxdxbxegedabagacad #exfxcxdxbxegedabagacad