-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_zshrc
186 lines (155 loc) · 5.41 KB
/
dot_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
180
181
182
183
184
185
186
# -*-mode:sh-*- vim:ft=zsh
#
# ~/.zshrc
# =============================================================================
#
#
zmodload zsh/zprof
# Hide default user from local prompt.
export DEFAULT_USER="${USER}"
# Automatically update without prompting.
export DISABLE_UPDATE_PROMPT="false"
# Uncomment the following line to change how often to auto-update (in days).
export UPDATE_ZSH_DAYS=7
# Reduce delay of loading the editor
# $KEYTIMEOUT controls the number of milliseconds that must pass
# before a key press is read.
export KEYTIMEOUT=1
# -- Plugins --------------------------------------------------
#
# Install zpm-zsh
if [[ ! -f ~/.zpm/zpm.zsh ]]; then
git clone --recursive https://github.com/zpm-zsh/zpm ~/.zpm
fi
source ~/.zpm/zpm.zsh
# Pull in OMZ (doesn't actually source anything)
zpm load @omz
zpm load \
@omz/lib/functions \
@omz/lib/prompt_info_functions \
@omz/lib/git \
@omz/lib/compfix \
@omz/lib/grep \
@omz/lib/termsupport \
@omz/lib/spectrum \
@omz/lib/history \
@omz/lib/key-bindings \
@omz/lib/completion
# Load some OMZ plugins and theme
zpm load \
@omz/git \
@omz/colored-man-pages \
@omz/vi-mode
VI_MODE_RESET_PROMPT_ON_MODE_CHANGE=true
VI_MODE_SET_CURSOR=true
bindkey -M vicmd 'V' edit-command-line # this remaps `vv` to `V` (but overrides `visual-mode`)
# Plugins for local host
zpm if-not ssh load \
zdharma-continuum/fast-syntax-highlighting \
zpm-zsh/zsh-history-substring-search \
zpm-zsh/zsh-autosuggestions,async \
zsh-users/zsh-completions,async \
zpm-zsh/zsh-better-npm-completion,async
autoload -U compinit && compinit
# Disable autosuggestion for large buffers.
export ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE="50"
# Enable aynchronous mode.
export ZSH_AUTOSUGGEST_USE_ASYNC=true
# Bind keys for zsh-history-substring-search. Plugin must be loaded
# after fast-syntax-highlighting.
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
if (( ${+commands[conda]} )); then
zpm load @github/esc/conda-zsh-completion
export CONDA_ENVS="/usr/local/anaconda3/envs"
conda_path="$(whence -cp conda)"
#
# >>> conda initialize >>>
#
__conda_setup="$($conda_path 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
. "/opt/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
#
# <<< conda initialize <<<
#
fi
if (( ${+commands[fd]} )) && (( ${+commands[rg]} )) && (( ${+commands[fzf]} )) && (( ${+commands[bat]} )); then
zpm load @github/unixorn/fzf-zsh-plugin
export FZF_DEFAULT_COMMAND='fd --type f --color=never --ignore-case --no-ignore --hidden --follow'
export FZF_DEFAULT_OPTS="
--bind 'f1:execute(bat --paging=always --color=always {})'
--bind 'f2:execute($EDITOR {})+abort'
--bind 'ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort'
--bind 'ctrl-z:toggle-up'
--bind '?:toggle-preview'
--preview='bat --number --color=always {} | head -700' --preview-window='right:50%:hidden'
--color header:italic
--header 'Press CTRL-Y to copy command into clipboard - F2 to open - CTRL-Z to toggle selection'"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
# Search for files
export FZF_ALT_C_COMMAND='fd --type d --color=never --no-ignore --ignore-case --hidden --follow '
# Search recent commands
export FZF_CTRL_R_OPTS="$FZF_DEFAULT_OPTS"
fi
# Load custom code from separate configuration file.
if [[ -f "$HOME"/.zsh_functions ]]; then source "$HOME"/.zsh_functions; fi
if [[ -f "$HOME"/.host_functions.zsh ]]; then source "$HOME"/.host_functions.zsh; fi
# Load aliases
# TODO why is this not working in warp?
if [[ -a "$HOME"/.zsh_aliases ]]; then
source "$HOME"/.zsh_aliases
fi
# -- Prompt styles ----------------------------------
#
# Light mode is the default. Check if apple settings are for darkmode
if [[ -f "$HOME"/.zsh_dark-notify.zsh ]]; then
source "$HOME"/.zsh_dark-notify.zsh
set_terminal_to_dark_mode
# TODO use evry and background
# while :; do
# (( ${+commands[dark-notify]} )) && dark-notify -c '$HOME/.zsh_dark-notify.zsh'
# done &
fi
# Starship cross-shell prompt
#
# Install starship
if (( ${+commands[starship]} )); then
export STARSHIP_LOG=error
eval "$(starship init zsh)"
fi
# -- Initialize other tools ----------------------------------------
#
#
# Alternative to cd
#
# The default command is `z` add the `--cmd cd` option to
# replaces `cd` command.
if (( ${+commands[zoxide]} )); then
export _ZO_ECHO=1
eval "$(zoxide init zsh)"
else
echo "zoxide not found"
fi
# The following enables shell integration w/ iterm2
# https://iterm2.com/documentation-shell-integration.html
export ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX=1
source ~/.iterm2_shell_integration.zsh
if (( ${+commands[atuin]} )); then
eval "$(atuin init zsh)"
fi
if (( ${+commands[git-machete]} )); then
eval "$(git machete completion zsh)"
fi
if (( ${+commands[scala-cli]} )); then
# >>> scala-cli completions >>>
fpath=("/Users/tkolleh/Library/Application Support/ScalaCli/completions/zsh" $fpath)
compinit
fi