-
Notifications
You must be signed in to change notification settings - Fork 1
/
zshrc
122 lines (116 loc) · 5.1 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
# ~/.zshrc
# __ __ ______
# /\ \ __/\ \/\ __ \
# \ \ \/\ \ \ \ \ \_\ \
# \ \ \ \ \ \ \ \ _ /
# \ \ \_/ \_\ \ \ \\ \
# \ \____^___/\ \_\ \_\
# \/__//__/ \/_/\/_/
################################################################################
# TERMINAL SETTINGS
################################################################################
# ALIASES
# alias to source .zshrc
alias src='[ -r ~/.zshrc ] && . ~/.zshrc'
# aliases
[ -r ~/.dotfiles/aliasrc ] && . ~/.dotfiles/aliasrc
HISTFILE=~/.zsh_history
HISTSIZE=1000
SAVEHIST=1000
setopt autocd beep extendedglob nomatch notify
bindkey -e # emacs mode
################################################################################
# SET UP PROMPT
################################################################################
export STARSHIP_CONFIG=~/.dotfiles/starship-zsh.toml
eval "$(starship init zsh)"
################################################################################
# TAB COMPLETION
################################################################################
# https://zsh.sourceforge.io/Doc/Release/Completion-Widgets.html#Completion-Matching-Control
# https://thevaluable.dev/zsh-completion-guide-examples/
# https://mybyways.com/blog/macos-zsh-configuration
# add other completion systems
zstyle ':completion:*' completer _extensions _complete _approximate
# case-insensitive matching only if there are no case-sensitive matches
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
# tab complete select visually
zstyle ':completion:*' menu select verbose yes
# color of directories
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
# color of descriptions
zstyle ':completion:*:*:*:*:descriptions' format '%F{cyan}%B-- %d --%b%f'
# explain corrections
zstyle ':completion:*:*:*:*:corrections' format '%F{yellow}%B-- %d (%e) --%b%f'
# show messages
zstyle ':completion:*:messages' format '%F{purple}%B-- %d --%b%f'
# show when there are no matches
zstyle ':completion:*:warnings' format '%F{magenta}%B-- no matches found --%b%f'
# group the different type of matches under their descriptions
zstyle ':completion:*' group-name ''
# change type of list depending on how many matches
zstyle ':completion:*' file-list list=20 insert=10
# shift tab tab completes backwards
bindkey '^[[Z' reverse-menu-complete
# brew completion
if type brew &>/dev/null
then
# FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
case ":$FPATH:" in
*:$(brew --prefix)/share/zsh/site-functions:*) ;;
*) FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}" ;;
esac
fi
# initialize advanced tab completion
autoload -Uz compinit && compinit
# add auto complete of dot files
_comp_options+=(globdots)
# tab completion with highlighting
zmodload -i zsh/complist
################################################################################
# CONDA
################################################################################
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/homebrew/Caskroom/miniconda/base/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh" ]; then
. "/opt/homebrew/Caskroom/miniconda/base/etc/profile.d/conda.sh"
else
export PATH="/opt/homebrew/Caskroom/miniconda/base/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
################################################################################
# ITERM2 SHELL INTEGRATION
################################################################################
test -e "${HOME}/.iterm2_shell_integration.zsh" &&
source "${HOME}/.iterm2_shell_integration.zsh" ||
echo "no iterm2 shell integration"
################################################################################
# FZF
################################################################################
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# unbind <m-c> because <esc>c is often pressed
[[ $- =~ i ]] && bindkey -r '\ec'
#bindkey "\ef" fzf-cd-widget
################################################################################
# ZSH AUTOCOMPLETE AND SYNTAX HIGHLIGHTING
# https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/main.md
# set | grep ZSH_HIGHLIGHT_STYLES | tr " " '\n'
################################################################################
source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
# MUST BE AT END
source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/main.md
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
typeset -A ZSH_HIGHLIGHT_STYLES
ZSH_HIGHLIGHT_STYLES[alias]='fg=magenta,bold'
ZSH_HIGHLIGHT_STYLES[command]='fg=blue'
ZSH_HIGHLIGHT_STYLES[builtin]='fg=blue,bold'
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]='fg=green'
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]='fg=magenta'
ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')