-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc_linux
117 lines (94 loc) · 3.39 KB
/
zshrc_linux
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
# .zshrc
################################################################################
## 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 '
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='%(?.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 '
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
################################################################################
# Some example alias instructions
# If these are enabled they will be used instead of any instructions
# they may mask. For example, alias rm='rm -i' will mask the rm
# application. To override the alias instruction use a \ before, ie
# \rm will call the real rm not the alias.
#
# Interactive operation...
# alias rm='rm -i'
# alias cp='cp -i'
# alias mv='mv -i'
alias ls='ls --color --show-control-chars --time-style=long-iso'
alias dir='ls --color=auto --format=vertical'
alias vdir='ls --color=auto --format=long'
alias ll='ls -l' # long list
alias la='ls -al' # all but . and ..
alias grep='grep --color=auto'
alias df='df -h'
alias du='du -h'
alias tmux='tmux -u'
export TERM=xterm-256color
## ==================== misc
unset USERNAME
## 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:|=*'
export HISTSIZE=10000
# python
PYTHONIOENCODING=utf8
ulimit -n 65535
export TMOUT=0
## ========= prevent tmux from sourcing this file more than once
if [ "$TMUX" != "" ]; then
echo "new tmux window started, skip sourcing bash_profile"
return
fi
## ==================== path
PATH=$HOME/bin:$PATH
export PATH
MANPATH=$HOME/opt/*/*/*/man:`manpath`
export MANPATH
# hosts
export HOSTALIASES=$HOME/.hosts
# less, default config
export LESS="-i -R"
# vim: ft=sh et: