-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdot_zshrc
147 lines (117 loc) · 3.96 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
#!/bin/env zsh
bindkey -e # emacs mode in zsh
setopt no_beep
setopt histignorealldups
setopt sharehistory
SAVEHIST=65535
HISTFILE=~/.zsh_history
# homebrew for linux envvars
if [ -d /home/linuxbrew/ ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
# Adds ~/.local/bin to PATH
if [ -d "$HOME/.local/bin" ] && [[ ! "$PATH" == *$HOME/.local/bin* ]]; then export PATH="$PATH:$HOME/.local/bin"; fi
# volta
if type volta >/dev/null 2>&1; then
export VOLTA_HOME="$HOME/.volta"
if [[ ! "$PATH" == *"$VOLTA_HOME"/bin* ]]; then export PATH="$VOLTA_HOME/bin:$PATH"; fi
fi
# default editor
if type vim >/dev/null 2>&1; then EDITOR=vim; fi
if type nvim >/dev/null 2>&1; then EDITOR=nvim; fi
export EDITOR
# ripgrep, Makes $HOME/.ripgreprc the default configuration.
if [ -f "$HOME/.ripgreprc" ]; then
# RIPGREP_CONFIG_PATH is required for ripgrep to respect the config.
export RIPGREP_CONFIG_PATH="$HOME/.ripgreprc"
fi
# homebrew autocomplete
if type brew >/dev/null 2>&1; then
# homebrew zsh environment
if [ -d "$(brew --prefix)/share/zsh/site-functions" ]; then
# FPATH must be declared before calling compinit for zsh.
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
fi
# node-version-manager
if [ -d "$(brew --prefix nvm)" ]; then
export NVM_DIR="$HOME/.nvm"
nvmsh="$(brew --prefix)/opt/nvm/nvm.sh"
[ -s "$nvmsh" ] && \. "$nvmsh" # This loads nvm
unset nvmsh
# IMPORTANT: bash_completion also loads zsh as of 2022/06/30.
bashCompletion="$(brew --prefix)/opt/nvm/etc/bash_completion"
if [ -s "$bashCompletion" ]; then
# shellcheck source=/dev/null
source "$bashCompletion"
fi
unset bashCompletion
fi
fi
if type zoxide >/dev/null 2>&1; then eval "$(zoxide init bash)"; fi
fzfShellDir="/usr/share/doc/fzf/examples" # Default on Ubuntu 20.04
if type brew >/dev/null 2>&1; then
fzfShellDir="$(brew --prefix)/opt/fzf/shell"
if [[ ! "$PATH" == *"$(brew --prefix)"/opt/fzf/bin* ]]; then
# Append fzf/bin to the PATH since homebrew does not.
PATH="$PATH:$(brew --prefix)/opt/fzf/bin"
export PATH
fi
fi
if [ -d "$fzfShellDir" ]; then
if [[ $- == *i* ]]; then
# shellcheck source=/dev/null
source "$fzfShellDir/completion.zsh" 2> /dev/null
fi
# shellcheck source=/dev/null
source "$fzfShellDir/key-bindings.zsh"
fi
unset fzfShellDir
# .zshrc.local, to override any settings from this .zshrc file.
if [ -f "$HOME/.zshrc.local" ]; then
# shellcheck source=/dev/null
source "$HOME/.zshrc.local"
fi
if [[ -o interactive ]]; then
# Use modern completion system
autoload -Uz compinit
compinit
if type oh-my-posh >/dev/null 2>&1; then
promptVariation='.minimal'
if [[ -n "${WT_SESSION}" ]]
then
promptVariation=''
fi
if [[ -n "${TERM_PROGRAM}" ]]
then
if [[ 'VSCode' == "${TERM_PROGRAM}" ]]
then
promptVariation=''
fi
fi
eval "$(oh-my-posh --init --shell zsh --config ~/.dotfiles-prompt$promptVariation.omp.json)"
else
autoload -Uz promptinit
promptinit
prompt adam1
fi
if type dotnet >/dev/null 2>&1; then
# zsh parameter completion for the dotnet CLI
_dotnet_zsh_complete()
{
local completions=("$(dotnet complete "$words")")
reply=( "${(ps:\n:)completions}" )
}
compctl -K _dotnet_zsh_complete dotnet
fi
fi
getSourceLocations () {
find -L "$HOME/Source" -mindepth 1 -maxdepth 3 -type d | grep -v '\.git'
}
editSourceLocation () { $EDITOR "$(getSourceLocations | fzf)" || return; }
getSourceLocation () { getSourceLocations | fzf || return; }
setSourceLocation () { cd "$(getSourceLocations | fzf)" || return; }
pushSourceLocation () { pushd "$(getSourceLocations | fzf)" || return; }
alias esl=editSourceLocation
alias gsl=getSourceLocation
alias ssl=setSourceLocation
alias psl=pushSourceLocation