-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc
201 lines (169 loc) · 6.29 KB
/
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
############################################################################
## System shell configuration (system-dependent config before zsh) #
############################################################################
if [[ $OSTYPE == darwin* ]]; then
# Enable homebrew when it were installed on /opt/homebrew
[ -f /opt/homebrew/bin/brew ] && eval $(/opt/homebrew/bin/brew shellenv)
brew_prefix=$(brew --prefix)
## To replace binary to linux version, install followings by brew
## brew install coreutils findutils gnu-tar gnu-sed gawk grep
## brew install gnutls gnu-indent gnu-getopt gnu-time gnu-units gnu-which
# coreutils binary
coreutils_path="$brew_prefix/opt/coreutils/libexec/gnubin"
[ -d $coreutils_path ] && PATH="$coreutils_path:$PATH"
unset coreutils_path
# coreutils manpage
coreutils_manpath="$brew_prefix/opt/coreutils/libexec/gnuman"
[ -d $coreutils_manpath ] && MANPATH="$coreutils_manpath:$MANPATH"
unset coreutils_manpath
# findutils binary
findutils_path="$brew_prefix/opt/findutils/libexec/gnubin"
[ -d $findutils_path ] && PATH="$findutils_path:$PATH"
unset findutils_path
# findutils manpage
findutils_manpath="$brew_prefix/opt/findutils/libexec/gnuman"
[ -d $findutils_manpath ] && MANPATH="$findutils_manpath:$MANPATH"
unset findutils_manpath
# gnu-tar binary
tar_path="$brew_prefix/opt/gnu-tar/libexec/gnubin"
[ -d $tar_path ] && PATH="$tar_path:$PATH"
unset tar_path
# gnu-tar manpath
tar_manpath="$brew_prefix/opt/gnu-tar/libexec/gnuman"
[ -d $tar_manpath ] && MANPATH="$tar_manpath:$MANPATH"
unset tar_manpath
# gnu-sed binary
sed_path="$brew_prefix/opt/gnu-sed/libexec/gnubin"
[ -d $sed_path ] && PATH="$sed_path:$PATH"
unset sed_path
# gnu-sed manpage
sed_manpath="$brew_prefix/opt/gnu-sed/libexec/gnuman"
[ -d $sed_manpath ] && MANPATH="$sed_manpath:$MANPATH"
unset sed_manpath
# gawk binary
awk_path="$brew_prefix/opt/gawk/libexec/gnubin"
[ -d $awk_path ] && PATH="$awk_path:$PATH"
unset awk_path
# gawk manpage
awk_manpath="$brew_prefix/opt/gawk/libexec/gnuman"
[ -d $awk_manpath ] && MANPATH="$awk_manpath:$MANPATH"
unset awk_manpath
# grep binary
grep_path="$brew_prefix/opt/grep/libexec/gnubin"
[ -d $grep_path ] && PATH="$grep_path:$PATH"
unset grep_path
# grep manpage
grep_manpath="$brew_prefix/opt/grep/libexec/gnuman"
[ -d $grep_manpath ] && MANPATH="$grep_manpath:$MANPATH"
unset grep_manpath
# gnutls binary
gnutls_path="$brew_prefix/opt/gnutls/bin"
[ -d $gnutls_path ] && PATH="$gnutls_path:$PATH"
unset gnutls_path
# gnutls manpage
gnutls_manpath="$brew_prefix/opt/gnutls/share/man"
[ -d $gnutls_manpath ] && MANPATH="$gnutls_manpath:$MANPATH"
unset gnutls_manpath
# gnu-indent binary
indent_path="$brew_prefix/opt/gnu-indent/libexec/gnubin"
[ -d $indent_path ] && PATH="$indent_path:$PATH"
unset indent_path
# gnu-indent manpage
indent_manpath="$brew_prefix/opt/gnu-indent/libexec/gnuman"
[ -d $indent_manpath ] && MANPATH="$indent_manpath:$MANPATH"
unset indent_manpath
# gnu-getopt binary
getopt_path="$brew_prefix/opt/gnu-getopt/bin"
[ -d $getopt_path ] && PATH="$getopt_path:$PATH"
unset getopt_path
# gnu-getopt manpage
getopt_manpath="$brew_prefix/opt/gnu-getopt/share/man"
[ -d $getopt_manpath ] && MANPATH="$getopt_manpath:$MANPATH"
unset getopt_manpath
# gnu-time binary
time_path="$brew_prefix/opt/gnu-time/libexec/gnubin"
[ -d $time_path ] && PATH="$time_path:$PATH"
unset time_path
# gnu-time does not have manpage
# gnu-units binary
units_path="$brew_prefix/opt/gnu-units/libexec/gnubin"
[ -d $units_path ] && PATH="$units_path:$PATH"
unset units_path
# gnu-units manpage
units_manpath="$brew_prefix/opt/gnu-units/libexec/gnuman"
[ -d $units_manpath ] && MANPATH="$units_manpath:$MANPATH"
unset units_manpath
# gnu-which binary
which_path="$brew_prefix/opt/gnu-which/libexec/gnubin"
[ -d $which_path ] && PATH="$which_path:$PATH"
unset which_path
# gnu-which manpage
which_manpath="$brew_prefix/opt/gnu-which/libexec/gnuman"
[ -d $which_manpath ] && MANPATH="$which_manpath:$MANPATH"
unset which_manpath
fi
############################################################################
## Basic z-shell usage configuration (with oh-my-zsh) #
############################################################################
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# zsh and Oh-my-zsh config aliases
alias zshconfig="vi ~/.zshrc"
alias omzconfig="vi ~/.oh-my-zsh"
# ZSH Theme and plugins
ZSH_THEME="jsyoo5b"
plugins=(
git sudo command-not-found
# zsh-completions
fast-syntax-highlighting
autojump
tmux tmuxinator
)
COMPLETION_WAITING_DOTS="true"
# Reveal aliased commands
export ZSH_PLUGINS_ALIAS_TIPS_REVEAL=1
export ZSH_PLUGINS_ALIAS_TIPS_REVEAL_TEXT="Actual command: "
# History setting
HIST_STAMPS="dd.mm.yyyy"
# zsh-completion setting
#autoload -U compinit && compinit
# tmux plugin configuration
export ZSH_TMUX_UNICODE=true
# Load oh-my-zsh with given configuration
source $ZSH/oh-my-zsh.sh
# Detect if current shell is running on WSL
if [[ -z "$WSL_DISTRO_NAME" ]]; then
if [[ $OSTYPE == darwin* ]]; then
# WSL cannot run macOS, skip
elif [[ "$(</proc/version)" == *([Mm]icrosoft|WSL)* ]]; then
# When the kernel version has Microsoft or WSL
WSL_DISTRO_NAME=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
fi
export DISPLAY=:0
else
# When the $WSL_DISTRO_NAME defined, current shell is running on native
export DISPLAY=$(grep -oP '(?<=^nameserver ).+' /etc/resolv.conf):0
fi
# When the WSL distro found, attach after hostname
if [[ ! -z "$WSL_DISTRO_NAME" ]]; then
ZSH_THEME_CONF[HOST_SUFFIX]="%F{yellow}/${WSL_DISTRO_NAME}"
fi
############################################################################
## User configuration (General shell setting) #
############################################################################
# manual path
export MANPATH="/usr/local/man:$MANPATH"
# Set default editor
export VISUAL=vim
export EDITOR="$VISUAL"
# Language environment
export LANG=en_US.UTF-8
# Import alias and shell config file
[ -f ~/.zsh_aliases ] && source ~/.zsh_aliases
# Import development envirnment config file
[ -f ~/.zsh_devconfig ] && source ~/.zsh_devconfig
# Enable fzf
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# Reset exit code to 0 for this script
# (Short-circuit condition check & apply may change exit code)
true