-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc
179 lines (135 loc) · 4.37 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# zshrc customizations -*- shell-script -*-
# detect machine first!
UNAME_S=`uname -s`
# most of the things are taken from hemant.
setopt correct
# Use Emacs keybinds
bindkey -e
PS1='%2~> '
setopt prompt_subst
autoload colors zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
colors
fi
PR_NOCOLOUR="%{$terminfo[sgr0]%}"
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
eval C_$color='$PR_NOCOLOR%{$terminfo[bold]$fg[${(L)color}]%}'
eval CL_$color='$PR_NOCOLOR%{$fg[${(L)color}]%}'
done
C_NOCOLOUR="$PR_NOCOLOR%{$terminfo[sgr0]%}"
function precmd() {
head_info=$(git symbolic-ref HEAD 2> /dev/null)
rvm_use=$(rvm info|egrep -C 1 'homes'|grep 'gem'|cut -d\: -f 2|cut -d\" -f 2 )
if [[ $rvm_use =~ 'not set' ]]; then
rvm_flag='system'
else
rvm_flag=$rvm_use[(ws:/:)-1]
fi
RPROMPT='$C_RED$rvm_flag$C_NOCOLOUR'
if [[ $head_info =~ '^refs*' ]]; then
git_prefix="git:("
git_suffix=")"
git_status=""
branch_name=$head_info[(ws:/:)-1]
output=$(git diff-files --exit-code --quiet)
if [[ $? == 0 ]]; then
git_status=">"
else
git_status="*"
fi
PROMPT='%2~ \
$C_RED$git_prefix$C_GREEN$branch_name$C_RED$git_suffix$C_CYAN$git_status$C_NOCOLOUR '
else
PROMPT='%2~> '
fi
}
#history stuff
## Command history configuration
HISTFILE=$HOME/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt hist_ignore_dups # ignore duplication command history list
setopt share_history # share command history data
setopt hist_verify
setopt inc_append_history
setopt extended_history
setopt hist_expire_dups_first
# completion related stuff
## fixme - the load process here seems a bit bizarre
setopt noautomenu
setopt complete_in_word
setopt always_to_end
unsetopt flowcontrol
WORDCHARS=''
autoload -U compinit
compinit
zmodload -i zsh/complist
## case-insensitive (all),partial-word and then substring completion
if [ "x$CASE_SENSITIVE" = "xtrue" ]; then
zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
unset CASE_SENSITIVE
else
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
fi
zstyle ':completion:*' list-colors ''
unsetopt MENU_COMPLETE
#setopt AUTO_MENU
# should this be in keybindings?
bindkey -M menuselect '^o' accept-and-infer-next-history
zstyle ':completion:*:*:*:*:*' menu yes select
# zstyle ':completion:*:*:*:*:processes' force-list always
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w"
# Load known hosts file for auto-completion with ssh and scp commands
if [ -f ~/.ssh/known_hosts ]; then
zstyle ':completion:*' hosts $( sed 's/[, ].*$//' $HOME/.ssh/known_hosts )
zstyle ':completion:*:*:(ssh|scp):*:*' hosts `sed 's/^\([^ ,]*\).*$/\1/' ~/.ssh/known_hosts`
fi
#end of completion related stuff
# nice trick from github
# parse /opt and update PATH, MANPATH
MYOPT=$HOME/opt
if [ -d $MYOPT ]; then
for d in $(ls $MYOPT); do
# update PATH with bin, sbin.
if [ -d "$MYOPT/$d/bin" ]; then
export PATH=$MYOPT/$d/bin:$PATH
fi
if [ -d "$MYOPT/$d/sbin" ]; then
export PATH=$MYOPT/$d/sbin:$PATH
fi
# update MANPATH with share/man.
if [ -d "$MYOPT/$d/share/man" ]; then
export MANPATH=$MYOPT/$d/share/man:$MANPATH
fi
done
fi
export PATH=/usr/local/bin:$PATH
export EDITOR='emacsclient'
# custom colors
# hate bold characters in ls or dir.
# if [ -e "$HOME/.dircolors" ]; then
# eval `dircolors -b $HOME/.dircolors`
# fi
# export where actual dot-files exist
# this is a dirty-hack at present.
export MYDOTFILES=`dirname $(ls -al $HOME/.zshrc | cut -d'>' -f2)`
# finally enable all aliases.
if [ -e "$MYDOTFILES/shell.d/alias" ]; then
source "$MYDOTFILES/shell.d/alias"
fi
# add texbin to $PATH
PATH=$PATH:/usr/texbin
# Homebrew
export PATH=/opt/homebrew/bin:/opt/homebrew/sbin:$PATH
# nvm stuff
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# pnpm
export PNPM_HOME="/Users/yuva/Library/pnpm"
export PATH="$PNPM_HOME:$PATH"
# pnpm end
# rvm stuff.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion