-
Notifications
You must be signed in to change notification settings - Fork 1
/
.zshrc
131 lines (112 loc) · 3.25 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
# Terminal art
rustmon print --hide-name --name random
# Plugin manager
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
if [ ! -d $ZINIT_HOME ]; then
mkdir -p "$(dirname $ZINIT_HOME)"
git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
fi
source "$ZINIT_HOME/zinit.zsh"
# Plugins
zinit light zsh-users/zsh-autosuggestions
zinit light zsh-users/zsh-completions
zinit light zsh-users/zsh-syntax-highlighting
zinit light Aloxaf/fzf-tab
zinit light MichaelAquilina/zsh-auto-notify
# Snippets
zinit snippet OMZP::git
zinit snippet OMZP::sudo
zinit snippet OMZP::command-not-found
# Load completions
autoload -Uz compinit && compinit
zinit cdreplay -q
autoload -U select-word-style
select-word-style bash
# Keybindings
bindkey -e
bindkey '^p' history-search-backward
bindkey '^n' history-search-forward
bindkey '^[[1;5D' backward-word
bindkey '^[[1;5C' forward-word
# History
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.zsh_history
HISTDUPE=erase
# zsh options
setopt appendhistory
setopt sharehistory
setopt hist_ignore_space
setopt hist_ignore_all_dups
setopt hist_save_no_dups
setopt hist_find_no_dups
# Envs
export EDITOR=nvim
export MANPAGER="$EDITOR +Man!"
export PATH=$HOME/.local/bin:$PATH
export AUTO_NOTIFY_THRESHOLD=20
export AUTO_NOTIFY_TITLE="Hey! '%command' has just finished"
export AUTO_NOTIFY_BODY="It completed in %elapsed seconds"
# Aliases
alias ls='lsd --tree --depth 1 --group-dirs=first'
alias lsr='lsd --recursive --depth 1 --group-dirs=first'
alias v="nvim"
alias cat="bat --theme base16"
alias bt="btop"
alias dil="docker images"
alias dcl="docker container ls -a"
alias gc="git clone"
alias upgr="sudo pacman -Syyu"
alias aupgr="paru -Sua"
alias pinst="pip install"
alias plist="pip list"
alias wgup="wg-quick up"
alias wgdown="wg-quick down"
alias awgup="awg-quick up"
alias awgdown="awg-quick down"
alias zshconf="$EDITOR ~/.zshrc && source ~/.zshrc"
# Completion styling
zstyle ':completion:*' matcher-list \
'm:{[:lower:]}={[:upper:]}' \
'l:|=* r:|=*' \
'r:|=*'
zstyle ':completion:*' completer _complete _approximate
zstyle ':completion:*:*:*:*:files' ignored-patterns ''
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*' menu no
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'lsd --color=always --icon=always $realpath'
# Functions
detect_virtualenv() {
if [[ -z "$VIRTUAL_ENV" ]] ; then
# If env folder is found, activate the virtualenv
if [[ -d ./venv ]] ; then
source ./venv/bin/activate
elif [[ -d ./.venv ]] ; then
source ./.venv/bin/activate
fi
else
# Check if the current folder belongs to the earlier VIRTUAL_ENV folder
# If not, deactivate the virtual environment
parentdir="$(dirname "$VIRTUAL_ENV")"
if [[ "$PWD"/ != "$parentdir"/* ]] ; then
deactivate
fi
fi
}
ddac() {
docker rm -vf $(docker ps -aq)
}
ddai() {
docker rmi -f $(docker images -aq)
}
traceroute-mapper() {
traceroute=$(traceroute -q1 $* | sed ':a;N;$!ba;s/\n/%0A/g')
xdg-open "https://stefansundin.github.io/traceroute-mapper/?trace=$traceroute"
}
# Run Python virtualenv detection script
autoload -U add-zsh-hook
add-zsh-hook chpwd detect_virtualenv
# Shell integrations
eval "$(fzf --zsh)"
eval "$(zoxide init zsh --cmd cd)"
eval "$(starship init zsh)"