-
Notifications
You must be signed in to change notification settings - Fork 2
/
zshrc_mine
executable file
·255 lines (201 loc) · 7.71 KB
/
zshrc_mine
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
alias startx="ssh-agent startx"
# -----------------------------------------------
#
# Set up the Environment
# -----------------------------------------------
#TERM=byobu
EDITOR=vim
PAGER=less
RSYNC_RSH=/usr/bin/ssh
FIGNORE='.o:.out:~'
DISPLAY=:0.0
# colored filename/directory completion
# Attribute codes:
# 00 none 01 bold 04 underscore 05 blink 07 reverse 08 concealed
# Text color codes:
# 30 black 31 red 32 green 33 yellow 34 blue 35 magenta 36 cyan 37 white
# Background color codes:
# 40 black 41 red 42 green 43 yellow 44 blue 45 magenta 46 cyan 47 white
LS_COLORS='no=0:fi=0:di=1;34:ln=1;36:pi=40;33:so=1;35:do=1;35:bd=40;33;1:cd=40;33;1:or=40;31;1:ex=1;32:*.tar=1;31:*.tgz=1;31:*.arj=1;31:*.taz=1;31:*.lzh=1;31:*.zip=1;31:*.rar=1;31:*.z=1;31:*.Z=1;31:*.gz=1;31:*.bz2=1;31:*.tbz2=1;31:*.deb=1;31:*.pdf=1;31:*.jpg=1;35:*.jpeg=1;35:*.gif=1;35:*.bmp=1;35:*.pbm=1;35:*.pgm=1;35:*.ppm=1;35:*.pnm=1;35:*.tga=1;35:*.xbm=1;35:*.xpm=1;35:*.tif=1;35:*.tiff=1;35:*.png=1;35:*.mpg=1;35:*.mpeg=1;35:*.mov=1;35:*.avi=1;35:*.wmv=1;35:*.ogg=1;35:*.mp3=1;35:*.mpc=1;35:*.wav=1;35:*.au=1;35:*.swp=1;30:*.pl=36:*.c=36:*.cc=36:*.h=36:*.core=1;33;41:*.gpg=1;33:'
ZLS_COLORS="$LS_COLORS"
COLORTERM=yes
PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:~/bin
# history saves 50,000 in it if we want to open it
# only the last 1000 are part of backward searching
HISTFILE=~/.zshhistory
HISTSIZE=1000
SAVEHIST=50000
# share history across terminal sessions
setopt SHARE_HISTORY
setopt EXTENDED_HISTORY
# ignore dupes
setopt HIST_IGNORE_ALL_DUPS
setopt HISTVERIFY
# complete on a space character
bindkey ' ' magic-space
# allow editing of the text on the current command line with v (cmd mode)
autoload -U edit-command-line
zle -N edit-command-line
bindkey -M vicmd v edit-command-line
# we like the calculator built into the shell
autoload -U zcalc
export TERM EDITOR PAGER RSYNC_RSH CVSROOT FIGNORE DISPLAY NNTPSERVER COLORTERM PATH HISTFILE HISTSIZE SAVEHIST
# output colored grep
export GREP_OPTIONS='--color=auto'
export GREP_COLOR='7;31'
# gpg key
# deb building info
# EC2 stuff
[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char
# -----------------------------------------------
# Prompt Setup
# -----------------------------------------------
setopt promptsubst
autoload -U promptinit && promptinit
autoload -U zrecompile
# -----------------------------------------------
# Zsh keybindings
# -----------------------------------------------
# auto pushd
setopt autocd autopushd pushdignoredups
bindkey -v
zstyle :compinstall filename '/home/rharding/.zshrc'
autoload -Uz compinit && compinit
# case-insensitive tab completion for filenames (useful on Mac OS X)
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '-- %B%d%b --'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
#------------------------------------------------------------------------------
# -----------------------------------------------
# Setup
# -----------------------------------------------
setopt \
no_beep \
correct \
auto_list \
complete_in_word \
auto_pushd \
pushd_ignoredups \
complete_aliases \
extended_glob \
zle
# map jj as the esc key for vim mode
bindkey "jj" vi-cmd-mode
#------------------------------------------------------------------------------
# -----------------------------------------------
# Shell Aliases
# -----------------------------------------------
## Command Aliases
alias x=exit
alias c=clear
alias b=byobu
alias s=screen
alias r='screen -R'
alias vi='vim'
alias gv='gvim &!'
alias ls='ls --color=auto -F'
alias l='ls -lAFh --color=auto'
alias ld='ls -ltr --color=auto'
alias sls='screen -ls'
alias zrc='vim ~/.zshrc'
alias cdw='cd ~/src'
alias o='open'
alias dv='dirs -v'
alias hist='history -rd'
alias zc='zcalc'
## Pipe Aliases (Global)
alias -g L='|less'
alias -g G='|grep'
alias -g T='|tail'
alias -g H='|head'
alias -g W='|wc -l'
alias -g S='|sort'
# directory aliases
src=~/src
#alias for ssh tunnels
alias tun="ssh -f -N "
compdef _ssh tun
# custom command aliases
alias usage='print -l -- ${(o)history%% *} | uniq -c | sort -nr | head -n 10';
#------------------------------------------------------------------------------
# -----------------------------------------------
# GIT STUFF
# -----------------------------------------------
setopt prompt_subst
autoload colors
colors
autoload -Uz vcs_info
#set some colors
for COLOR in RED GREEN YELLOW WHITE BLACK CYAN; do
eval PR_$COLOR='%{$fg[${(L)COLOR}]%}'
eval PR_BRIGHT_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
done
PR_RESET="%{${reset_color}%}";
#
# set formats
# # %b - branchname
# # %u - unstagedstr (see below)
# # %c - stangedstr (see below)
# # %a - action (e.g. rebase-i)
# # %R - repository path
# # %S - path in the repository
FMT_BRANCH="${PR_GREEN}%b%u%c${PR_RESET}" # removed %c for stagedstr e.g. master¹²
FMT_ACTION="(${PR_CYAN}%a${PR_RESET}%)" # e.g. (rebase-i)
FMT_PATH="%R${PR_YELLOW}/%S" # e.g. ~/repo/subdir
# check-for-changes can be really slow.
# you should disable it, if you work with large repositories
# zstyle ':vcs_info:*:prompt:*' check-for-changes true
# zstyle ':vcs_info:*:prompt:*' unstagedstr "¹" # display ¹ if there are unstaged changes
# zstyle ':vcs_info:*:prompt:*' stagedstr "²" # display ² if there are staged changes
#
zstyle ':vcs_info:*:prompt:*' actionformats "${FMT_BRANCH}${FMT_ACTION}//" "${FMT_PATH}"
zstyle ':vcs_info:*:prompt:*' actionformats "${FMT_BRANCH} ${FMT_ACTION}//" "${FMT_PATH}"
zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}//" "${FMT_PATH}"
zstyle ':vcs_info:*:prompt:*' nvcsformats "" "%~"
function precmd {
vcs_info 'prompt'
}
# handle vi NORMAL/INSERT mode change
ZLE_VIMODE="#"
ZLE_COLOR="blue"
function zle-line-init zle-keymap-select {
ZLE_VIMODE="${${KEYMAP/vicmd/N}/(main|viins)/I}"
ZLE_COLOR="${${KEYMAP/vicmd/red}/(main|viins)/green}"
zle reset-prompt
}
zle -N zle-line-init
zle -N zle-keymap-select
function lprompt {
local brackets=$1
local color1=$2
local color2=$3
local bracket_open="${color2}${brackets[1]}${PR_RESET}"
local bracket_close="${color2}${brackets[2]}"
local vimode='${ZLE_VIMODE}'
local col3='%{$fg_bold[$ZLE_COLOR]%}'
local git='$vcs_info_msg_0_'
local cwd="${color2}%B%1~%b"
PROMPT="${PR_RESET}${bracket_open}${git}${cwd} ${col3}${vimode}${PR_RESET} ${bracket_close}%# ${PR_RESET}"
# PROMPT="${PR_RESET}${bracket_open}${git}${cwd} ${ZLE_COLOR}${vimode}${PR_RESET} ${bracket_close}%# ${PR_RESET}"
}
function rprompt {
local brackets=$1
local color1=$2
local color2=$3
local bracket_open="${color1}${brackets[1]}${PR_RESET}"
local bracket_close="${color1}${brackets[2]}${PR_RESET}"
local colon="${color1}:"
local at="${color1}@${PR_RESET}"
local user_host="${color2}%n${at}${color2}%m"
local vcs_cwd='${${vcs_info_msg_1_%%.}/$HOME/~}'
local cwd="${color2}%B%20<..<${vcs_cwd}%<<%b"
local inner="${user_host}${colon}${cwd}"
RPROMPT="${PR_RESET}${bracket_open}${inner}${bracket_close}${PR_RESET}"
}
lprompt '[]' $BR_BRIGHT_BLACK $PR_WHITE
rprompt '()' $BR_BRIGHT_BLACK $PR_WHITE
source ~/src/workit/workit.sh