-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc_mac
138 lines (116 loc) · 4.3 KB
/
zshrc_mac
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
################################################################################
## begin of prompt
################################################################################
# bak
# PROMPT='%(?.0 %F{green}%B√.%F{red}%? x)%b%f %D{20%y-%m-%d %H:%M:%S} %F{green}%B%n@%M%b%f %F{063}%B%10~
# $%b%f '
# break down into parts
prompt1='%(?.0 %F{green}%B√.%F{red}%? x)%b%f %D{20%y-%m-%d %H:%M:%S} '
prompt2='%F{green}%B%n@%M%b%f %F{063}%B%10~
$%b%f '
# hook, pre command execution
function preexec {
# timer=${timer:-$SECONDS} # SECONDS is built in zsh but not precise enough
# timer=$(($(date +%s%0N)/1000000)) # gnu date
timer=$(perl -MTime::HiRes=time -e 'printf "%.0f\n", time*1000')
}
# hook, before next command
function precmd {
if [[ -n ${timer} ]]; then
# now=$(($(date +%s%0N)/1000000)) # gnu date
now=$(perl -MTime::HiRes=time -e 'printf "%.0f\n", time*1000')
elapsed=$((${now}-${timer}))
unset timer
if [[ ${elapsed} -gt 0 ]]; then
# RPROMT is the prompt from RIGHT, we can also use it
# RPROMPT="${elapsed} ms"
PROMPT="${prompt1}${elapsed}ms ${prompt2}"
else
PROMPT="${prompt1}${prompt2}"
fi
fi
}
PROMPT="${prompt1}${prompt2}"
# repeat prompt for time measuing, and record in self-defined history file
repeat-last-prompt-accept-line() {
# record history
echo "`date +"%Y-%m-%d %H:%M:%S"`\t${PWD}\t${BUFFER}" >> ~/.my_zsh_history
echo ""
PROMPT="${prompt1}${prompt2}"
zle reset-prompt
zle accept-line
}
zle -N repeat-last-prompt-accept-line
bindkey "^M" repeat-last-prompt-accept-line
################################################################################
## end of prompt
################################################################################
# check manuals of ls and find CLICOLOR for more help
export LSCOLORS='Exfxcxdxbxegedabagacad'
alias ls='ls -G'
alias ll='ls -lG'
alias la='ls -AlG'
alias dir='ls -G'
alias grep='grep --colour=auto'
export TERM=xterm-256color
## auto completion file name ignore case
autoload -Uz compinit && compinit
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*'
## prevent tmux from sourcing this file more than once
# on OSX, before sourcing this profile, tmux uses /usr/libexec/path_helper to
# generate a default PATH, which may reorder the PATH we set before
# we have to force set PATH instead of skipping sourcing this file and source
# it again
if [ "$TMUX" != "" ]; then
# echo "new tmux window started, skip sourcing bash_profile"
# preset paths are defined in:
# /etc/paths stores preset PATH, /etc/manpaths stores preset MANPATH
# /etc/paths.d/ for user defined preset path
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
# return
fi
## history
# HISTSIZE=5000 # session history size
# SAVEHIST=1000 # saved history
# HISTFILE=~/.zshistory # history file
## path
## use system's util to determin javahome
# export JAVA_HOME=$(/usr/libexec/java_home)
export JAVA_HOME=$HOME/opt/jdk/jdk8
export GOROOT=$HOME/opt/go/go-1.18
export GOPATH=$GOROOT:~/Documents/workspace/go/lib
PATH=$HOME/go/go-1.18/bin:$PATH
export M2_REPO=~/.m2/repository
export M2_HOME=~/tools/maven/3.3.3
# for autotools,autoconf macros
export ACLOCAL_PATH=$HOME/installed-from-src/libtool/current-version/share/aclocal/:$HOME/installed-from-src/pkg-config/current-version/share/aclocal
### latex
PATH=$HOME/installed-from-src/latex/texlive/2018/bin/x86_64-darwin:$PATH
### rust and cargo
export CARGO_HOME=$HOME/installed-from-src/rust
export RUSTUP_HOME=$CARGO_HOME
PATH=$CARGO_HOME/bin:$PATH
### ruby
export GEM_HOME=$HOME/installed-from-src/ruby/gems
PATH=$GEM_HOME/bin:$PATH
PATH=~/installed-from-src/ruby/current-version/bin:$PATH
### my bin
PATH=$HOME/bin:$PATH
## focus issue for iterm2: ^[[O^[[I
alias focusfix='printf "\e[?1004l"'
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
# custom completion
source $HOME/config/env_config/zsh/completion.zsh
# less, default config
export LESS="-i -R"
# editor for crontab etc.
export EDITOR=$HOME/bin/vim
export PATH
# vim: ft=sh tw=1000: