-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
164 lines (137 loc) · 5.33 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
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
echo -ne '\e[5 q' # use beam shape cursor
(( ${+commands[direnv]} )) && emulate zsh -c "$(direnv export zsh)"
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
(( ${+commands[direnv]} )) && emulate zsh -c "$(direnv hook zsh)"
cd_up_widget() {
cd ..
zle reset-prompt
zle accept-line
}
# Create the widget
zle -N cd_up_widget
bindkey '^U' cd_up_widget
CUSTOM_COMPLETION_DIR="$HOME/zsh_completions"
# Add the custom completion directory to fpath
fpath=($CUSTOM_COMPLETION_DIR $fpath)
autoload -Uz compinit
compinit
# _vim_completion() {
# # Use the _files builtin to generate file completions only, excluding directories
# _path_files -W "$PWD" "*(.)"
# }
#
# # Associate the completion function with the vim command
# compdef _vim_completion vim
if [[ -f "/opt/homebrew/bin/brew" ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
# Enable colors
autoload -U colors && colors
# needed specifically for Lazygit and more generically this makes configs more Linux compatible
export XDG_CONFIG_HOME="$HOME/.config"
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
if [[ $(command -v nvim) ]]; then
export EDITOR=nvim
export MANPAGER='nvim +Man! -c "set laststatus=0"'
fi
export BAT_THEME="ansi"
# ======== History ========
export HISTSIZE=100000
export HISTFILE=~/.zsh_history
export SAVEHIST=$HISTSIZE
export HISTDUP=erase
setopt append_history # Append history to the history file, rather than overwriting it
setopt hist_ignore_space # Ignore commands that start with a space in the history
setopt hist_ignore_all_dups # remove older duplicate entries from history
setopt share_history # share history between different instances of the shell
setopt hist_reduce_blanks # remove blanks from history items
setopt inc_append_history # save history entries as soon as they are entered
setopt hist_save_no_dups # Do not save duplicate commands in the history
setopt hist_find_no_dups # Do not display duplicate commands when searching the history
# ======== Plugin mgmt ========
load_plugins() {
# install/load plugins
PLUGIN_DIR="$HOME/.zsh/plugins"
if [[ ! -d "$PLUGIN_DIR" ]]; then
mkdir -p "$PLUGIN_DIR"
fi
PLUGINS=(
zdharma-continuum/fast-syntax-highlighting
zsh-users/zsh-autosuggestions
zsh-users/zsh-completions
zsh-users/zsh-history-substring-search
Aloxaf/fzf-tab
jeffreytse/zsh-vi-mode
)
for plugin in $PLUGINS
do
local plugin_name=`basename $plugin`
local plugin_path="${PLUGIN_DIR}/$plugin_name"
if [[ ! -d "$plugin_path" ]]; then
# echo "will clone https://github.com/$plugin at $plugin_path"
git clone https://github.com/$plugin "$plugin_path"
else
# echo "$plugin is already installed...at $plugin_path"
source "$plugin_path/$plugin_name.plugin.zsh"
fi
done
}
load_plugins
ZVM_VI_EDITOR="vim"
# The plugin will auto execute this zvm_after_init function
function zvm_after_init() {
source <(fzf --zsh)
bindkey "" forward-word # ctrl + right
bindkey "" backward-word # ctrl + left
bindkey '^[[A' history-substring-search-up # up
bindkey '^[[B' history-substring-search-down # down
}
# ======== Completion ========
# setup directory colors
# on Mac the command is gdircolors, on Linux it's dircolors
if command -v gdircolors &> /dev/null; then
eval $(gdircolors -b)
elif command -v dircolors &> /dev/null; then
eval $(dircolors -b)
fi
zstyle ':completion:::::' completer _expand _complete _ignored _approximate
# zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*:descriptions' format '[%d]'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*' menu no
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -T -L=3 --color=always $realpath'
zstyle ':fzf-tab:*' switch-group '<' '>'
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'ls --color $realpath'
# zstyle ':fzf-tab:*' fzf-command ftb-tmux-popup
# custom fzf flags
# NOTE: fzf-tab does not follow FZF_DEFAULT_OPTS
zstyle ':fzf-tab:*' fzf-flags --height ~40% --color=fg:1,fg+:2
# ======== Setup key bindings ========
bindkey -e
bindkey '^A' beginning-of-line
bindkey '^E' end-of-line
# ======== Dotfiles mgmt ========
# git init --bare $HOME/dotfiles
# alias dconf='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME'
# dconf config --local status.showUntrackedFiles no
# echo "alias dconf='/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME'" >> $HOME/.bashrc
alias dconf='/usr/bin/git --git-dir=/Users/rbhanot/dotfiles/ --work-tree=$HOME'
# ======== Load tools ========
eval "$(devbox global shellenv)" 2> /dev/null
[[ -f "~/.temporal.zsh" ]] && source ~/.temporal.zsh
# source <(fzf --zsh)
# eval "$(direnv hook zsh)"
eval "$(zoxide init zsh)"
alias zi=__zoxide_zi
[ -f "$HOME/fzf_config.zsh" ] && source "$HOME/"fzf_config.zsh
[ -f "$HOME/custom_config.zsh" ] && source "$HOME/custom_config.zsh"
export PATH="$PATH:$HOME/.local/bin:"
[[ -d /Users/Shared/DBngin/ ]] && export PATH="$PATH:/Users/Shared/DBngin/mysql/8.0.19/bin"
[[ -d $HOME/.volta ]] && export VOLTA_HOME="$HOME/.volta/bin"
[[ -d $HOME/.cargo ]] && export PATH="$PATH:$HOME/.cargo/bin"
source ~/powerlevel10k/powerlevel10k.zsh-theme
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh