-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.zshrc
More file actions
172 lines (137 loc) · 3.79 KB
/
.zshrc
File metadata and controls
172 lines (137 loc) · 3.79 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
# The following lines were added by compinstall
zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
zstyle :compinstall filename '~/.zshrc'
autoload -Uz compinit
compinit
# End of lines added by compinstall
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt beep notify
bindkey -e
# End of lines configured by zsh-newuser-install
# -*- mode: sh; -*-
# Dracula Theme v1.2.5
#
# https://github.com/dracula/dracula-theme
#
# Copyright 2019, All rights reserved
#
# Code licensed under the MIT license
# http://zenorocha.mit-license.org
#
# @author Zeno Rocha <hi@zenorocha.com>
# @maintainer Aidan Williams <aidanwillie0317@protonmail.com>
# Initialization {{{
source ~/.zsh/lib/async.zsh
autoload -Uz add-zsh-hook
setopt PROMPT_SUBST
async_init
# }}}
# Options {{{
# Set to 1 to show the date
DRACULA_DISPLAY_TIME=${DRACULA_DISPLAY_TIME:-0}
# Set to 1 to show the 'context' segment
DRACULA_DISPLAY_CONTEXT=${DRACULA_DISPLAY_CONTEXT:-0}
# Changes the arrow icon
DRACULA_ARROW_ICON=${DRACULA_ARROW_ICON:-➜}
# function to detect if git has support for --no-optional-locks
dracula_test_git_optional_lock() {
local git_version=${DEBUG_OVERRIDE_V:-"$(git version | cut -d' ' -f3)"}
local git_version="$(git version | cut -d' ' -f3)"
# test for git versions < 2.14.0
case "$git_version" in
[0-1].*)
echo 0
return 1
;;
2.[0-9].*)
echo 0
return 1
;;
2.1[0-3].*)
echo 0
return 1
;;
esac
# if version > 2.14.0 return true
echo 1
}
# use --no-optional-locks flag on git
DRACULA_GIT_NOLOCK=${DRACULA_GIT_NOLOCK:-$(dracula_test_git_optional_lock)}
# }}}
# Status segment {{{
# arrow is green if last command was successful, red if not,
# turns yellow in vi command mode
# }}}
PROMPT='%n@%m: '
# Directory segment {{{
PROMPT+='%F{blue}%B%c '
# }}}
# Async git segment {{{
dracula_git_status() {
cd "$1"
local ref branch lockflag
(( DRACULA_GIT_NOLOCK )) && lockflag="--no-optional-locks"
ref=$(=git $lockflag symbolic-ref --quiet HEAD 2>/tmp/git-errors)
case $? in
0) ;;
128) return ;;
*) ref=$(=git $lockflag rev-parse --short HEAD 2>/tmp/git-errors) || return ;;
esac
branch=${ref#refs/heads/}
if [[ -n $branch ]]; then
echo -n "${ZSH_THEME_GIT_PROMPT_PREFIX}${branch}"
local git_status icon
git_status="$(LC_ALL=C =git $lockflag status 2>&1)"
if [[ "$git_status" =~ 'new file:|deleted:|modified:|renamed:|Untracked files:' ]]; then
echo -n "$ZSH_THEME_GIT_PROMPT_DIRTY"
else
echo -n "$ZSH_THEME_GIT_PROMPT_CLEAN"
fi
echo -n "$ZSH_THEME_GIT_PROMPT_SUFFIX"
fi
}
dracula_git_callback() {
DRACULA_GIT_STATUS="$3"
zle && zle reset-prompt
async_stop_worker dracula_git_worker dracula_git_status "$(pwd)"
}
dracula_git_async() {
async_start_worker dracula_git_worker -n
async_register_callback dracula_git_worker dracula_git_callback
async_job dracula_git_worker dracula_git_status "$(pwd)"
}
add-zsh-hook precmd dracula_git_async
PROMPT+='$DRACULA_GIT_STATUS'
ZSH_THEME_GIT_PROMPT_CLEAN=") %F{green}%B✔ "
ZSH_THEME_GIT_PROMPT_DIRTY=") %F{yellow}%B✗ "
ZSH_THEME_GIT_PROMPT_PREFIX="%F{cyan}%B("
ZSH_THEME_GIT_PROMPT_SUFFIX="%f%b"
# }}}
# ensure vi mode is handled by prompt
function zle-keymap-select zle-line-init {
if [[ $KEYMAP = vicmd ]]; then
psvar[1]=vicmd
else
psvar[1]=''
fi
zle reset-prompt
zle -R
}
zle -N zle-line-init
zle -N zle-keymap-select
PROMPT+='%(1V:%F{yellow}:%(?:%F{green}:%F{red}))${DRACULA_ARROW_ICON}%F '
# Ensure effects are reset
PROMPT+='%f%b'
export PATH=$PATH:~/.cargo/bin
export PATH=$PATH:/usr/local/opt/llvm/bin/
export PATH=$PATH:/home/bin
alias e=emacsclient -n
alias v=vim
alias s=subl
alias ll=ls -lah
export ANSIBLE_NOCOWS=1
GPG_TTY=$(tty)
export GPG_TTY