-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathzshrc
More file actions
194 lines (165 loc) · 6.42 KB
/
Copy pathzshrc
File metadata and controls
194 lines (165 loc) · 6.42 KB
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
# line editing and default editor
export EDITOR=vim
bindkey -v
# ftp
export FTP_PASSIVE=1
export TIMEFMT=$'\nreal\t%E\nuser\t%U\nsys\t%S'
export REPORTTIME=10
# aliases
alias l='/opt/local/libexec/gnubin/ls -alh --color'
alias lsd='ls -ld *(-/DN)'
alias pshell='phocoa shell'
alias bigdirs='du -Sh ./ | grep -v "^-1" | grep "^[0-9]\\+M"'
alias base64urldecode='tr "\-_" "+/" | base64 -d | more'
alias vi=vim
alias vipager='vim -R -'
alias vgit="git status --porcelain | awk '{print \$2}' | xargs -o vim -o"
alias pb='git planbox'
alias rake='noglob rake'
alias ramdisk='diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://4194304`'
alias curltime="curl -w \"@$HOME/.curl-format.txt\" -o /dev/null -s "
# suffix aliases
alias -s php=vim
alias -s tpl=vim
alias -s rb=vim
alias -s conf=vim
alias -s log=vim
alias -s png="open -a Preview"
alias -s jpg="open -a Preview"
alias -s gif="open -a Preview"
alias -s pdf="open -a Preview"
# php helpers
alias xdebug-on='export XDEBUG_MODE="debug" XDEBUG_SESSION=1'
alias xdebug-off='unset XDEBUG_MODE XDEBUG_SESSION'
alias xdebug-profile='php -dxdebug.mode=profile -dxdebug.output_dir=`pwd` $*'
alias xdebug-php='php -dzend_extension=xdebug $*'
# Prompts: see http://aperiodic.net/phil/prompt/
setopt prompt_subst
autoload -U colors
colors
# grep the current repo for the given string, skipping files/directories that trip up grep or are undesirable in the search list
function repogrep() {
local DIR=`pwd`
local TARGET=.git
while [ ! -e $DIR/$TARGET -a $DIR != "/" ]; do
DIR=$(dirname $DIR)
done
test $DIR = "/" && echo "Couldn't find a repo from here..." && return 1
echo Searching from $DIR
find ${DIR}/ \
-type f \
-not -path '*/.git/*' \
-not -path '*/tags' \
-not -path '*/*min.js' \
-not -path "*/externals/*" \
-not -path "*/wwwroot/www/db_images/*" \
-not -path "*/wwwroot/www/coverage/*" \
-not -path "*/shared/*" \
-print0 \
| xargs -0 grep $*
}
git_current_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo " git@${ref#refs/heads/} "
}
function flushdns() {
(uname -a | grep Darwin > /dev/null 2>&1) && (dscacheutil -flushcache;sudo killall -HUP mDNSResponder)
}
function precmd { # runs before the prompt is rendered each time
# PROMPT
local exitstatus=$?
# show screen window # if available
if [ $WINDOW ]; then
PR_SCREEN="$WINDOW"
fi
# Combined left and right prompt configuration.
local smiley="%(?,%F{green}☺%f,%F{red}☹%f)"
[ $exitstatus -eq 0 ] && PR_LAST_EXIT="${smiley} " || PR_LAST_EXIT="${smiley} %{$fg_bold[red]%}%?%{$reset_color%}"
# put in here so length recalulation works well and prompts don't wrap
PROMPT='[\
$PR_SCREEN\
$(git_current_branch)\
]:\
${PR_LAST_EXIT}\
> '
# /PROMPT
# BUGFIX for older zsh that overwrite the last line of command output if there is no trailing newline.
# See http://zsh.sourceforge.net/FAQ/zshfaq03.html, 3.23
# Skip defining precmd if the PROMPT_SP option is available.
if ! eval '[[ -o promptsp ]] 2>/dev/null'; then
# Output an inverse char and a bunch spaces. We include
# a CR at the end so that any user-input that gets echoed
# between this output and the prompt doesn't cause a wrap.
print -nP "%B%S%#%s%b${(l:$((COLUMNS-1)):::):-}\r"
fi
}
RPROMPT=" $USERNAME@%M:%~" # prompt for right side of screen
##### HISTORY CONFIGURAION
HISTSIZE=5000 # How many lines of history to keep in memory
HISTFILE=~/.zsh_history # Where to save history to disk
SAVEHIST=5000 # Number of history entries to save to disk
#HISTDUP=erase # Erase duplicates in the history file
# The next 3 configue cross-session history sharing and immediately write all commands to the shared history file
# (rather than at session exit which risks losing useful history)
setopt appendhistory # Append history to the history file (no overwriting)
setopt sharehistory # Share history across terminals
setopt incappendhistory # Immediately append to the history file, not just when a term is killed
# Now that we have shared hisory, we want it for "search" but not up-arrow/down-arrow, which should just be session-local history
# From: https://superuser.com/questions/446594/separate-up-arrow-lookback-for-local-and-global-zsh-history
# Note: zkbd's ${key[Up/Down]} would be equivalent but requires running `zkbd` to generate a terminal profile.
# Using hardcoded xterm escape sequences instead since they work on all modern macOS terminals.
#bindkey "${key[Up]}" alans-up-prompt
bindkey "^[[A" alans-up-prompt
#bindkey "${key[Down]}" alans-down-prompt
bindkey "^[[B" alans-down-prompt
alans-up-prompt() {
zle set-local-history 1
zle up-line-or-search
zle set-local-history 0
}
zle -N alans-up-prompt
alans-down-prompt() {
zle set-local-history 1
zle down-line-or-search
zle set-local-history 0
}
zle -N alans-down-prompt
##### END HISTORY CONFIGURATION
HOSTTITLE=${(%):-%n@%m}
TITLE=$HOSTTITLE
function title (){
if (( ${#argv} == 0 )); then
TITLE=$HOSTTITLE
else
TITLE=$*
fi
# send title to gui terminal title bar
case $TERM in
xterm* | *rxvt | screen)
print -Pn "\e]0;$TITLE \a"
esac
}
# The following lines were added by compinstall
zstyle ':completion:*' completer _expand _complete
zstyle ':completion:*' completions 1
zstyle ':completion:*' glob 1
zstyle -e ':completion::complete:s(cp|sh):*' hosts "reply=( \$( gawk '
/^#/ { next }
/^Host\>/ { \$1 = \"\"; print }
ARGIND > 1 && !FS_set { FS = \"[, ]\"; FS_set++; \$0 = \$0; }
FS_set { print \$1, \$2 }
' ~/.ssh/config ~/.ssh/known_hosts )
)"
zstyle :compinstall filename '~/.zshrc'
zstyle :compinstall filename '~/.stuff/zsh/rake-completion.zsh'
autoload -Uz compinit
if [ $USER = "root" ]; then
# sudo'd shells run this zshrc; root was writing out zcompdump and thus breaking perms for the main user. have root skip dumping; the file should be there anyway.
compinit -D
else
compinit
fi
# End of lines added by compinstall
# override with local settings
source ~/.zshrc.local
## Anything below here was probably added automatically and should be moved to ~/.zshrc.local