-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
182 lines (148 loc) · 6.3 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block, everything else may go below.
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
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=100000
SAVEHIST=100000
unsetopt autocd beep
bindkey -e
# End of lines configured by zsh-newuser-install
# Colorize dir lists if colors are available
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dir_colors && eval "$(dircolors -b ~/.dir_colors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto --group-directories-first'
fi
# Make completion:
# - Case-insensitive.
# - Accept abbreviations after . or _ or - (ie. f.b -> foo.bar).
# - Substring complete (ie. bar -> foobar).
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
# Colorize completions using default `ls` colors.
zstyle ':completion:*' list-colors "${(@s.:.)LS_COLORS}"
# enable menu selection for completion
zstyle ':completion:*' menu select
zstyle ':completion:*' special-dirs true
autoload -Uz compinit
compinit
#------------------------------------------------------------------------------
# Options
#------------------------------------------------------------------------------
# Enable autocompletion of hidden files without typing a dot at the start
setopt globdots
setopt autoparamslash # Tab completing directory appends a slash
setopt correct # Command auto-correction
setopt correctall # Argument auto-correction
setopt interactivecomments # allow comments, even in interactive shells
setopt appendhistory # Append history to the history file (no overwriting)
# setopt inc_append_history # Appends every command to the history file once it is executed
# setopt share_history # Reloads the history whenever you use it
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
export EDITOR='nvim'
bindkey '^[[3~' delete-char
# Ctrl + x, Ctrl + e opens default editor to enter a command
autoload -z edit-command-line
zle -N edit-command-line
bindkey "^X^E" edit-command-line
#-------------------------------------------------------------------------------
# Shell utility functions
#-------------------------------------------------------------------------------
# Make CTRL-Z background things and unbackground them.
function fg-bg() {
if [[ $#BUFFER -eq 0 ]]; then
fg
else
zle push-input
fi
}
zle -N fg-bg
bindkey '^Z' fg-bg
autoload -U add-zsh-hook
# Automatically show files in a directory after changing to it
function auto-ls-after-cd() {
emulate -L zsh
# Only in response to a user-initiated `cd`, not indirectly (e.g. via another
# function).
if [ "$ZSH_EVAL_CONTEXT" = "toplevel:shfunc" ]; then
ls -a
fi
}
add-zsh-hook chpwd auto-ls-after-cd
# adds `cdr` command for navigating to recent directories
autoload -Uz chpwd_recent_dirs cdr add-zsh-hook
add-zsh-hook chpwd chpwd_recent_dirs
# enable menu-style completion for cdr
zstyle ':completion:*:*:cdr:*:*' menu selection
# fall through to cd if cdr is passed a non-recent dir as an argument
zstyle ':chpwd:*' recent-dirs-default true
#-------------------------------------------------------------------------------
# Setup and load external tools
#-------------------------------------------------------------------------------
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)"
[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
source "${ZINIT_HOME}/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
zdharma-continuum/zinit-annex-readurl \
zdharma-continuum/zinit-annex-bin-gem-node \
zdharma-continuum/zinit-annex-patch-dl \
zdharma-continuum/zinit-annex-rust
# End of Zinit's installer chunk
# Zinit plugins
zinit for \
light-mode zsh-users/zsh-autosuggestions \
light-mode wfxr/forgit \
light-mode zdharma-continuum/zsh-diff-so-fancy \
light-mode kazhala/dotbare
zinit ice blockf
zinit light clarketm/zsh-completions
zinit as"depth=1" for \
light-mode romkatv/powerlevel10k
zinit pack"binary+keys" for fzf
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ -f ~/.p10k.zsh ]] && source ~/.p10k.zsh
#-------------------------------------------------------------------------------
# Setup shell environment
#-------------------------------------------------------------------------------
#
# Set window title for urxvt and co.
case "$TERM" in
xterm*|rxvt*|alacritty*)
precmd () {print -Pn "\e]0;%~ - $TERM \a"}
;;
esac
# Tell rg to read its config file
export RIPGREP_CONFIG_PATH=~/.config/.ripgreprc
# Use rg so only relevant files are selected
export FZF_DEFAULT_COMMAND='rg --files --hidden'
# To apply the command to CTRL-T as well
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
# start the agent automatically and ensure that only one ssh-agent process runs
if ! pgrep -u "$USER" ssh-agent > /dev/null; then
ssh-agent > "$XDG_RUNTIME_DIR/ssh-agent.env"
fi
if [[ ! "$SSH_AUTH_SOCK" ]]; then
eval "$(<"$XDG_RUNTIME_DIR/ssh-agent.env")"
fi
#-------------------------------------------------------------------------------
# Load Aliases and utility functions
#-------------------------------------------------------------------------------
[ -f ~/.aliases.sh ] && source ~/.aliases.sh
# Add yarn to path for globally installed yarn packages
# (`yarn global bin` would be better but slow as it stats the nvm usage)
export PATH="$PATH:$HOME/.yarn/bin"
export PATH="$HOME/.poetry/bin:$PATH"
# fnm
export PATH="/home/fabio/.local/share/fnm:$PATH"
eval "`fnm env`"
export PATH="$PATH:/home/fabio/.foundry/bin"
autoload -U +X bashcompinit && bashcompinit
complete -o nospace -C /usr/bin/terraform terraform