-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_zshrc
171 lines (119 loc) · 3.89 KB
/
dot_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
# zmodload zsh/zprof
# Load all stock functions (from $fpath files) called below.
# autoload -U compaudit
autoload -Uz compinit
for dump in ~/.zcompdump(N.mh+24); do
compinit
done
compinit -C
## History file configuration
[ -z "$HISTFILE" ] && HISTFILE="$HOME/.history"
HISTSIZE=50000
SAVEHIST=10000
## History command configuration
setopt extended_history # record timestamp of command in HISTFILE
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
setopt hist_ignore_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space
setopt hist_verify # show command with history expansion to user before running it
setopt inc_append_history # add commands to HISTFILE in order of execution
setopt share_history # share command history data
setopt hist_reduce_blanks # Pretty Obvious. Right?
function env_default() {
env | grep -q "^$1=" && return 0
export "$1=$2" && return 3
}
# Set up a custom prompt showing the node version being used
NVM_PROMPT_PREFIX="(⬡ "
NVM_PROMPT_SUFFIX=")"
# get the node.js version
function nvm_prompt_info() {
[[ -f "$NVM_DIR/nvm.sh" ]] || return
local nvm_prompt
nvm_prompt=$(node -v 2>/dev/null)
[[ "${nvm_prompt}x" == "x" ]] && return
nvm_prompt=${nvm_prompt:1}
echo "${NVM_PROMPT_PREFIX}${nvm_prompt}${NVM_PROMPT_SUFFIX}"
}
# By default, don't load nvm, and don't show any prompt
export NVM_NO_USE=true
# must occur before zsh-syntax-highlighting due to bug. (loaded in .zsh_plugins.sh)
autoload -Uz select-word-style
select-word-style default
zstyle ':zle:*' word-chars " /:@+|"
zstyle ':zle:*' word-style unspecified
source ~/.zsh_plugins.zsh
bindkey -M emacs '^P' history-substring-search-up
bindkey -M emacs '^N' history-substring-search-down
bindkey -e
# load modules
autoload -U zmv
autoload -U promptinit; promptinit
prompt pure
# fix issue in iterm?
export COLUMNS
alias svn=/usr/bin/svn
alias emacs="emacsclient -nc"
setopt no_beep
# Changing/making/removing directory
setopt auto_cd
setopt auto_pushd
setopt pushd_ignore_dups
setopt pushdminus
setopt multios
setopt prompt_subst
# Make zsh know about hosts already accessed by SSH
#zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })'
# emacs read only
er() {
emacs "$1" --eval '(setq buffer-read-only t)'
}
function ev; {
emacsclient --nw --eval '(view-file "$1")'
}
function E; {
emacsclient -t -a "" "/sudo::$@"
}
alias E3="SUDO_EDITOR=\"emacsclient -c -a emacs\" sudoedit"
insert_sudo () {
zle beginning-of-line; zle -U "sudo "
}
zle -N insert-sudo insert_sudo
bindkey "s" insert-sudo
# Meta-u to chdir to the parent directory
bindkey -s 'u' '^Ucd ..; ls^M'
# Remove default keyboard shortcuts C-s and C-q
stty stop undef
stty start undef
# URL encode something and print it.
function url-encode; {
setopt extendedglob
echo "${${(j: :)@}//(#b)(?)/%$[[##16]##${match[1]}]}"
}
# Search google for the given keywords.
function google; {
$VIEW "http://www.google.com/search?q=`url-encode "${(j: :)@}"`"
}
function cropopen; {
pdfcrop --resolution 72 "$1" && open "${1:t:r}-crop.pdf"
}
alias cat=bat
# Enable ls colors
export LSCOLORS="Gxfxcxdxbxegedabagacad"
alias ls='ls -G'
alias ll='ls -lh'
alias la='ls -lAh'
alias zmv='noglob zmv -W'
alias brewall="brew list | while read cask; do echo -n $cask; brew deps $cask | awk '{printf(\" %s \", ${0})}'; echo ''; done"
#source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# lazily run
rbenv() {
eval "$(command rbenv init - --no-rehash)"
rbenv "$@"
}
# zprof
# source antidote
source /usr/local/opt/antidote/share/antidote/antidote.zsh
# initialize plugins statically with ${ZDOTDIR:-~}/.zsh_plugins.txt
# antidote load
RPROMPT='$(nvm_prompt_info)'