forked from garybernhardt/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
162 lines (143 loc) · 4.41 KB
/
.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
# Set custom prompt
setopt PROMPT_SUBST
autoload -U promptinit
promptinit
prompt grb
# Initialize completion
autoload -U compinit
compinit
# Add paths
export PATH=/usr/local/sbin:/usr/local/bin:${PATH}
export PATH="$HOME/bin:$PATH"
# By default, ^S freezes terminal output and ^Q resumes it. Disable that so
# that those keys can be used for other things.
unsetopt flowcontrol
# Colorize terminal
alias ls='ls -G'
alias ll='ls -lG'
export LSCOLORS="ExGxBxDxCxEgEdxbxgxcxd"
export GREP_OPTIONS="--color"
# Nicer history
export HISTSIZE=100000
export HISTFILE="$HOME/.history"
export SAVEHIST=$HISTSIZE
# Use vim as the editor
export EDITOR=vi
# GNU Screen sets -o vi if EDITOR=vi, so we have to force it back.
set -o emacs
# Use C-x C-e to edit the current command line
autoload -U edit-command-line
zle -N edit-command-line
bindkey '\C-x\C-e' edit-command-line
# By default, zsh considers many characters part of a word (e.g., _ and -).
# Narrow that down to allow easier skipping through words via M-f and M-b.
export WORDCHARS='*?[]~&;!$%^<>'
# Highlight search results in ack.
export ACK_COLOR_MATCH='red'
# Aliases
t() {
if [ -e script/test ]; then
script/test $*
else
rspec --color spec
fi
}
alias f="script/features $*"
alias z="zeus $*"
alias r="script/rails $*"
function lack() {
# The +k clears the screen (it tries to scroll up but there's nowhere to
# go)
ack --group --color $* | less -r +k
}
function mcd() { mkdir -p $1 && cd $1 }
function cdf() { cd *$1*/ } # stolen from @topfunky
function das() {
cd ~/proj/destroyallsoftware.com/destroyallsoftware.com
pwd
. ~/Documents/filing/business/destroy\ all\ software\ llc/s3.sh
. ~/Documents/filing/business/destroy\ all\ software\ llc/braintree.sh
. ~/Documents/filing/business/destroy\ all\ software\ llc/cloudfront.sh
}
alias v="view -"
function m() {
if [[ "$1" == "das" ]]; then
mutt -F ~/.mutt/das.muttrc
else
~/proj/thelongpoll/thelongpoll/thelongpoll client -F ~/.mutt/$1.muttrc
fi
}
alias c="cd"
# Activate the closest virtualenv by looking in parent directories.
activate_virtualenv() {
if [ -f env/bin/activate ]; then . env/bin/activate;
elif [ -f ../env/bin/activate ]; then . ../env/bin/activate;
elif [ -f ../../env/bin/activate ]; then . ../../env/bin/activate;
elif [ -f ../../../env/bin/activate ]; then . ../../../env/bin/activate;
fi
}
# Find the directory of the named Python module.
python_module_dir () {
echo "$(python -c "import os.path as _, ${1}; \
print _.dirname(_.realpath(${1}.__file__[:-1]))"
)"
}
# By @ieure; copied from https://gist.github.com/1474072
#
# It finds a file, looking up through parent directories until it finds one.
# Use it like this:
#
# $ ls .tmux.conf
# ls: .tmux.conf: No such file or directory
#
# $ ls `up .tmux.conf`
# /Users/grb/.tmux.conf
#
# $ cat `up .tmux.conf`
# set -g default-terminal "screen-256color"
#
function up()
{
local DIR=$PWD
local TARGET=$1
while [ ! -e $DIR/$TARGET -a $DIR != "/" ]; do
DIR=$(dirname $DIR)
done
test $DIR != "/" && echo $DIR/$TARGET
}
# Switch projects
function p() {
proj=$(ls ~/proj | selecta)
if [[ -n "$proj" ]]; then
cd ~/proj/$proj
fi
}
# By default, ^S freezes terminal output and ^Q resumes it. Disable that so
# that those keys can be used for other things.
unsetopt flowcontrol
# Run Selecta in the current working directory, appending the selected path, if
# any, to the current command.
function insert-selecta-path-in-command-line() {
local selected_path
# Print a newline or we'll clobber the old prompt.
echo
# Find the path; abort if the user doesn't select anything.
selected_path=$(find * -type f | selecta) || return
# Append the selection to the current command buffer.
eval 'LBUFFER="$LBUFFER$selected_path"'
# Redraw the prompt since Selecta has drawn several new lines of text.
zle reset-prompt
}
# Create the zle widget
zle -N insert-selecta-path-in-command-line
# Bind the key to the newly created widget
bindkey "^S" "insert-selecta-path-in-command-line"
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
# Initialize RVM
#PATH=$PATH:$HOME/.rvm/bin
#[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
#export PATH="$HOME/.rbenv/bin:$PATH"
#eval "$(rbenv init -)"
#source /usr/local/share/chruby/chruby.sh
#source /usr/local/share/chruby/auto.sh