-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathzshrc.pre
More file actions
175 lines (136 loc) · 4.62 KB
/
zshrc.pre
File metadata and controls
175 lines (136 loc) · 4.62 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
#### Enable lazy loading support
source ~/.zsh/modules/zsh-defer/zsh-defer.plugin.zsh
#### Basic setup
# Kill XOFF, it is evil.
stty stop undef
#### Set options for grml zshrc
# We have our own function to set the title, so disable the support in grml
# TODO: This probably breaks dynamic hostname updating in the title
NOPRECMD=1
# Only regenerate the completion cache once daily. Confusingly this will either loop once (old file) or never, allowing us to use the cache
# when the file is < 24 hours old
for dump in ${ZDOTDIR:-$HOME}/.zcompdump(N.mh-24); do
zstyle ':grml:completion:compinit' arguments -C
done
#### Profiling
function enable_profiling() {
zmodload zsh/zprof
ZSH_PROFILE=1
unfunction enable_profiling
}
# Uncomment to enable
#enable_profiling
#### Homebrew
# Pre-set $HOMEBREW_PREFIX. This and other settings below will be reset by the `shellenv` parse,
# but this lets us do some preliminary setup so we can use basic things from homebrew before we
# have completely loaded.
if [[ -e /opt/homebrew/bin/brew ]]; then
HOMEBREW_PREFIX=/opt/homebrew
# Fallback for local installs on Intel
elif [[ -e ~/.homebrew/bin/brew ]]; then
HOMEBREW_PREFIX=~/.homebrew
fi
if [[ ! -z "$HOMEBREW_PREFIX" ]]; then
function setup_homebrew() {
eval $($HOMEBREW_PREFIX/bin/brew shellenv)
unfunction setup_homebrew
}
# As above, preconfigure part of homebrew so we can use it early.
# TODO: This is a little hacky, but it's very fast...tradeoffs.
PATH="$HOMEBREW_PREFIX/bin:$PATH"
FPATH="$HOMEBREW_PREFIX/share/zsh/site-functions:$FPATH"
# setup_homebrew will be invoked later to complete setup
fi
#### Additional paths
# Add local bin at the end, if it exists
if [[ -d ~/bin ]]; then
PATH=$PATH:~/bin
fi
#### Basic options we want everywhere
# Add some nice ls options
typeset -ga ls_options
ls_options=( -F )
#### Setup multiplexing
# Only multiplex for remote connections
if [[ ! -z "$SSH_TTY" ]]; then
# Immediately setup homebrew with no defer so we can use any installed versions of tmux, etc
if [[ ! -z "$HOMEBREW_PREFIX" ]]; then
setup_homebrew
fi
source ~/.zsh/zshrc.pre.tmux
# If this chooses to start a session and works correctly, it'll never return. Otherwise continue
# on to setup the local shell.
fi
##### Setup color scheme
# This will use OSC 4 escapes to configure colors in supported terminals. Only do this locally so
# an ssh session doesn't "infect" the host with color changes.
if [[ -z "$SSH_TTY" ]]; then
# Inside a function so we dont leak all these variables out of scope
function setup_colors() {
# Modified version of the Solarized scheme ported by Benjamin Staffin.
# https://github.com/benley/solarized-termcolor-osc4/tree/master
# Note that while many terminals allow custom colors, this method is universal (where supported).
# Solarized Colors
local base03="00/2b/36"
local base02="07/36/42"
local base01="58/6e/75"
local base00="65/7b/83"
local base0="83/94/96"
local base1="93/a1/a1"
local base2="ee/e8/d5"
local base3="fd/f6/e3"
local yellow="b5/89/00"
local orange="cb/4b/16"
local red="dc/32/2f"
local magenta="d3/36/82"
local violet="6c/71/c4"
local blue="26/8b/d2"
local cyan="2a/a1/98"
local green="85/99/00"
# Molokai colors
local molokai_yellow="e6/db/74"
local molokai_orange="fd/97/1f"
local molokai_orange2="ef/59/39"
local molokai_lightbrown="bc/a3/a3"
local molokai_red="f9/26/72"
local molokai_magenta="f9/26/72"
local molokai_blue="70/70/f0"
local molokai_violet="ae/81/ff"
local molokai_cyan="66/d9/ef"
local molokai_brightcyan="70/f0/f0"
local molokai_green="a6/e2/2e"
function cset() {
local ANSI=$1
local RGB=$2
printf "\x1b]4;$ANSI;rgb:${RGB}\a"
}
# I prefer the default colors, so leave this out for now
# Black
#cset 0 $base02
#cset 8 $base03
# Red
cset 1 $red
cset 9 $orange
# Green
cset 2 $green
cset 10 $molokai_green
# Yellow
cset 3 $yellow
cset 11 $molokai_yellow
# Blue
cset 4 $blue
cset 12 $molokai_blue
# Magenta
cset 5 $magenta
cset 13 $molokai_magenta
# Cyan
cset 6 $cyan
cset 14 $molokai_cyan
# White
cset 7 $base2
cset 15 $base3
unfunction cset
unfunction setup_colors
}
setup_colors
fi