-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc
129 lines (115 loc) · 3.77 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
export PATH=$HOME/.local/dotfile-scripts:$PATH
HOSTNAME=$(cat /etc/hostname)
if [[ $HOSTNAME == "professor-farnsworth" ]]; then
export GOPATH=$HOME/Documents/code/golang
#$HOME/.config/powerline/segments is used for custom ALE powerline segment
export PYTHONPATH=$HOME/.config/powerline/segments
export PATH=$HOME/.local/bin:$PATH
export PATH=/usr/local/go/bin:$PATH
export PATH=$GOPATH/bin:$PATH
export EDITOR=/usr/bin/vimx
export XDG_CONFIG_HOME=$HOME/.config/
#In order to get pasteboard functionality on Fedora, we need alias vim=vimx
alias vim=vimx
#Hostname unique color
PROMPT_COLOR=006
elif [[ $HOSTNAME == "cubert" ]]; then
export PATH=$HOME/.local/bin:$PATH
export GOPATH=$HOME/Documents/code/golang
export PATH=$GOPATH/bin:$PATH
export PATH=$HOME/.local/npm/bin:$PATH
export PATH="$HOME/.cargo/bin:$PATH"
export EDITOR=/usr/bin/vimx
alias vim=vimx
PROMPT_COLOR=006
elif [[ $HOSTNAME == "bender" ]]; then
#$HOME/.config/powerline/segments is used for custom ALE powerline segment
export PYTHONPATH=$HOME/.config/powerline/segments
export GOPATH=$HOME/Documents/code/golang
export PATH=$GOPATH/bin:$PATH
export PATH=$HOME/.local/bin:$PATH
export PATH=$HOME/.local/npm/bin:$PATH
export EDITOR=/usr/bin/vimx
alias vim=vimx
PROMPT_COLOR=003
elif [[ $HOSTNAME == "scooty-puff-jr" ]]; then
export PYTHONPATH=$HOME/.config/powerline/segments
export GOPATH=$HOME/Documents/code/golang
export PATH=$GOPATH/bin:$PATH
export PATH=$HOME/.local/bin:$PATH
export PATH=$HOME/.local/npm/bin:$PATH
export PATH="$HOME/.cargo/bin:$PATH"
export EDITOR=/usr/bin/vimx
alias vim=vimx
PROMPT_COLOR=004
elif [[ $HOSTNAME == "planet-express-ship" ]]; then
PROMPT_COLOR=002
elif [[ $HOSTNAME == "nibbler" ]]; then
export PATH=$HOME/.local/bin:$PATH
PROMPT_COLOR=009
else
PROMPT_COLOR=006
fi
#Load zplug and various plugins
source ~/.zsh/zplug/init.zsh
zplug 'lib/completion', from:oh-my-zsh
zplug 'lib/functions', from:oh-my-zsh
zplug 'lib/history', from:oh-my-zsh
zplug 'lib/key-bindings', from:oh-my-zsh
zplug 'lib/misc', from:oh-my-zsh
zplug 'lib/spectrum', from:oh-my-zsh
zplug 'lib/theme-and-appearance', from:oh-my-zsh
zplug "plugins/git", from:oh-my-zsh
zplug "plugins/docker", from:oh-my-zsh
zplug "plugins/colored-man-pages", from:oh-my-zsh
if ! zplug check --verbose; then
printf "Install? [y/N]: "
if read -q; then
echo; zplug install
fi
fi
zplug load
#Enable completion system
autoload -U compinit
compinit
unsetopt histverify
unsetopt share_history
unsetopt auto_cd
setopt auto_pushd
setopt prompt_subst
setopt extended_glob
alias cclip="xclip -selection clipboard"
tabs -4
function pls() {
until $@; do false; done
}
function plsboot() {
until ssh $@; do false; done
}
#Generates a prompt that detects if enough space is leftover for commands. If there isn't, command entry begins on the next line.
#Currently, the prompt length must be less than 5/8 of the terminal window
PROMPT_PREFIX='%{$FG[005]%}[%~]'
PROMPT_SUFFIX='%{$FG[$PROMPT_COLOR]%}%n@%M$%{$FX[reset]%} '
BASE_PROMPT=$PROMPT_PREFIX' '$PROMPT_SUFFIX
NEWLINE_PROMPT=$PROMPT_PREFIX$'\n'$PROMPT_SUFFIX
trap 'generate_prompt' WINCH
function generate_prompt() {
#Remove color code extras from BASE_PROMPT. Sed doesn't support the ? operator, I passed it through perl.
export STRIPPED_PROMPT=$(echo $BASE_PROMPT |perl -pe 's/%\{.*?%\}//g')
PROMPT_LENGTH=$(print -P $STRIPPED_PROMPT |wc -c)
#uses -lt rather than < because < does LEXOGRAPHIC comparison
if [[ $PROMPT_LENGTH -lt $(($(tput cols) * 5/8)) ]]; then
export PROMPT="$BASE_PROMPT"
else
export PROMPT="$NEWLINE_PROMPT"
fi
#Fixes virtualenv names not showing up
if [[ ! -z $VIRTUAL_ENV ]]; then
export PROMPT="($(basename $VIRTUAL_ENV))"$PROMPT
fi
}
#Generate a new prompt even if something changes our long path.
function precmd() {
generate_prompt
}
generate_prompt