forked from traefikturkey/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.zshrc
156 lines (125 loc) · 4.51 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
############################################################################
#
# Completions
#
############################################################################
zstyle ':completion:*' completer _complete _ignored _files
#zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' special-dirs true
# https://stackoverflow.com/questions/24226685/have-zsh-return-case-insensitive-auto-complete-matches-but-prefer-exact-matches
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
setopt globdots
setopt GLOB_COMPLETE
# make autocompletion
# https://unix.stackexchange.com/a/499322/3098
# zstyle ':completion:*:*:make:*' tag-order 'targets'
zstyle ':completion::complete:make::' tag-order targets
zstyle ':completion::complete:make:*:targets' ignored-patterns '*[?%\:]=*' '$(*)'
autoload -Uz compinit
compinit
############################################################################
#
# Plugins
#
############################################################################
source ~/.dotfiles/plugin-functions.sh
# export FZF_DEFAULT_OPTS="--ansi --no-info"
# plugin "Aloxaf/fzf-tab"
# zstyle ':completion:*' menu no
plugin "zsh-users/zsh-autosuggestions"
bindkey '^ ' autosuggest-accept # ctrl+space
plugin "zsh-users/zsh-completions"
plugin "zsh-users/zsh-syntax-highlighting"
plugin "joshskidmore/zsh-fzf-history-search"
plugin "djui/alias-tips"
############################################################################
#
# History
#
############################################################################
HISTFILE=~/.zsh_history
# https://zsh-manual.netlify.app/options#1624-history
export HISTSIZE=100000
export SAVEHIST=100000
export HISTTIMEFORMAT="[%F %T] "
setopt APPEND_HISTORY
setopt EXTENDED_HISTORY
setopt HIST_FIND_NO_DUPS
setopt HIST_IGNORE_DUPS
setopt HIST_REDUCE_BLANKS
setopt SHARE_HISTORY
############################################################################
#
# Keybindings
#
############################################################################
# home and end move cursor to respective line positions
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
# ctrl+b/f or ctrl+left/right: move word by word (backward/forward)
bindkey '^b' backward-word
bindkey '^f' forward-word
bindkey '^[[1;5D' backward-word
bindkey '^[[1;5C' forward-word
# ctrl+backspace: delete word before
bindkey '^H' backward-kill-word
# ctrl+delete: delete word after
bindkey "\e[3;5~" kill-word
############################################################################
#
# Git Prompt
#
############################################################################
autoload -Uz vcs_info
setopt prompt_subst
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:git:*' formats '%F{yellow}[%f%F{green}%b%f%F{yellow}]%f'
zstyle ':vcs_info:git:*' actionformats '%F{yellow}[%f%F{red}%b%f%F{yellow}]%f'
function +vi-git-untracked() {
if [[ $(git rev-parse --is-inside-work-tree 2>/dev/null) == 'true' ]] && \
[[ $(git status --porcelain | wc -l) -ne 0 ]]; then
hook_com[branch]='%F{red}'${hook_com[branch]}'%f'
fi
}
zstyle ':vcs_info:git+post-backend:*' hooks git-untracked
precmd() { vcs_info }
PROMPT='%F{green}%m%f:%F{blue}%~${vcs_info_msg_0_}%f>%(?: : )'
############################################################################
#
# Aliases
#
############################################################################
alias nix-gc='nix-store --gc'
alias nix-rs='sudo nixos-rebuild switch'
alias nix-code='code /etc/nixos/configuration.nix'
alias es='env | sort'
alias sz='source ~/.zshrc'
alias ez='$EDITOR ~/.zshrc'
alias dps='tput rmam; docker ps --format="table {{.Names}}\\t{{.ID}}\\t{{.Image}}\\t{{.RunningFor}}\\t{{.State}}\\t{{.Status}}" | (sed -u 1q; sort); tput smam'
alias history="history 1"
if type eza &> /dev/null; then
alias ls=eza
alias l='eza --color=auto -la --group-directories-first --group'
alias tree='eza --tree --level=2'
else
alias l='ls --color=auto -lhA --group-directories-first'
fi
############################################################################
#
# Exports
#
############################################################################
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export HOSTNAME=$(hostname)
export PATH="$HOME/.local/bin:$PATH"
if [[ -f ~/.dircolors ]] ; then
eval $(dircolors -b ~/.dircolors)
elif [[ -f /etc/DIR_COLORS ]] ; then
eval $(dircolors -b /etc/DIR_COLORS)
fi
if [[ "$TERM_PROGRAM" == "vscode" ]]; then
export EDITOR="code"
else
export EDITOR="nano"
fi