-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
109 lines (83 loc) · 3.66 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
################################################################
# .zshrc - ZSH session setup #
################################################################
# -> symlinked to ~/.config/zsh/.zshrc #
# #
# Executed when a new ZSH session is launched. #
# Setup plugins, zstyles, keybinds, functions, and options. #
################################################################
# if not running interactively, do nothing
[[ $- != *i* ]] && return
# install plugins -------------------------------------------- #
# initialize zinit zsh plugin manager
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"
# install/initialize zsh plugins
zinit light Aloxaf/fzf-tab
zinit light djui/alias-tips
zinit light jeffreytse/zsh-vi-mode
zinit light zsh-users/zsh-autosuggestions
zinit light zsh-users/zsh-completions
zinit light zsh-users/zsh-syntax-highlighting
# zstyles ---------------------------------------------------- #
# disable completion menu selection in favor of fzf-tab
zstyle ':completion:*' menu no
# allow partial tab completions: cd /u/lo/b⇥ -> /usr/local/bin
zstyle ':completion:*' list-suffixes zstyle ':completion:*'
# preview directory's content with eza when completing cd
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath'
zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'eza -1 --color=always $realpath'
# color tab completed paths
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
# initialize zsh completions
autoload -Uz compinit && compinit
# keybinds --------------------------------------------------- #
# zsh line editor keybindings
bindkey -v
bindkey '^p' history-search-backward
bindkey '^n' history-search-forward
# source functions ------------------------------------------- #
# zsh config directory
zsh_dir=${${ZDOTDIR}:-$HOME/.config/zsh}
if [[ -d $zsh_dir ]]; then
# source functions
for func_file in "$zsh_dir"/lib/*; do
source ${func_file}
done
fi
# set options ------------------------------------------------ #
# configure history file
HISTFILE="${XDG_CACHE_HOME}/zsh/.zsh_history"
SAVEHIST=4096 # number of history entries to save to history file
HISTSIZE=4096 # number of history entries loaded in memory
HISTFILESIZE=2048
# history
setopt APPEND_HISTORY # append to history file without overwriting
setopt HIST_IGNORE_DUPS # ignore contiguous history duplicates
setopt HIST_IGNORE_SPACE # do not append commands that start with a space
setopt SHARE_HISTORY # share history across terminals
# setopt hist_save_no_dups # remove older history entries that are dups of newer ones
# setopt inc_append_history # immediately append to history file, not just on term exit
# other
setopt auto_cd # auto change to dir without cd
setopt no_case_glob # enable case-insensitive tab completion and globbing
# setopt correct
# setopt correct_all
# initialize tools ------------------------------------------- #
# setup fzf key bindings and fuzzy completions
if (( $+commands[fzf] )); then
source <(fzf --zsh)
fi
# initialize zoxide directory hopper
if (( $+commands[zoxide] )); then
eval "$(zoxide init --cmd cd zsh)"
fi
# initialize shell prompt
if (( $+commands[oh-my-posh] )); then
eval "$(oh-my-posh init zsh --config ${XDG_CONFIG_HOME}/oh-my-posh/config.toml)"
fi
# cleanup ---------------------------------------------------- #
# remove duplicates from path arrays
typeset -gU PATH FPATH