-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
167 lines (139 loc) · 6.26 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
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
export PRINTER=M70
export PATH="$PATH:$HOME/.local/bin:$HOME/.go/bin"
export BROWSER=brave
# Editor exports
export VISUAL=nvim
export EDITOR="$VISUAL"
export FCEDIT="$VISUAL"
export MANPAGER='nvim +Man!'
export MANWIDTH=999
# Colorize less pages
export LESS_TERMCAP_mb=$'\e[1;32m'
export LESS_TERMCAP_md=$'\e[1;32m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;31m'
export BAT_THEME="ansi"
# History options
HISTFILE=~/.histfile
HISTSIZE=5000
SAVEHIST=5000
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
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.
setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
setopt interactivecomments # Allow typing comments at an interactive prompt
setopt CD_SILENT
# Aliases and Functions
alias ls='exa --git --classify --group-directories-first --sort=extension --color=always'
alias cat='bat'
alias shred='shred --remove --zero --iterations=4'
alias rm='rm -Iv'
alias c='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
alias info='info --vi'
alias ssh='TERM=xterm-256color ssh' # So ssh works properly with kitty
alias v='nvim'
alias icat='kitty +kitten icat'
alias gdb='gdb -q'
alias npm='npm --color=always'
alias sudo='sudo ' # Allow for aliases https://askubuntu.com/questions/22037/aliases-not-available-when-using-sudo
alias z='zathura --fork'
alias wasi-clang='/opt/wasi-sdk/bin/clang --sysroot /opt/wasi-sdk/share/wasi-sysroot'
alias rankmirrors='sudo reflector --country us --age 12 --protocol https --sort rate --save /etc/pacman.d/mirrorlist'
# https://stackoverflow.com/a/19358402
function mergepdf() {
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default \
-dNOPAUSE -dQUIET -dBATCH -dDetectDuplicateImages -dCompressFonts=true \
-r150 -sOutputFile="$1" "${@:1}"
}
# Prompt fanciness
autoload -Uz vcs_info add-zsh-hook
setopt PROMPT_SUBST
add-zsh-hook precmd vcs_info
zstyle ':vcs_info:git:*' formats '(%b) '
PROMPT='%F{blue}%~ %F{red}${vcs_info_msg_0_}%f%F{blue}
%#%f '
# Use emacs-like keybinds at the command line
bindkey -e
# fzf
source $HOME/.config/fzf/fzf.zsh
export FZF_DEFAULT_OPTS="-m --preview 'bat --style=numbers {} 2>/dev/null'"
# Keybinds
bindkey "^[[3~" delete-char # Make 'delete' actually delete
bindkey \^U backward-kill-line # CTRL-u works as in bash
bindkey "^[[1;5C" forward-word # CTRL-right moves right a word
bindkey "^[[1;5D" backward-word # CTRL-left moves left a word
### Added by Zinit's installer
if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then
print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit"
command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \
print -P "%F{33} %F{34}Installation successful.%f%b" || \
print -P "%F{160} The clone has failed.%f%b"
fi
source "$HOME/.local/share/zinit/zinit.git/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
### End of Zinit's installer chunk
zinit wait lucid blockf for \
atinit"zicompinit; zicdreplay" \
zdharma-continuum/fast-syntax-highlighting \
chisui/zsh-nix-shell \
atload"prompt_nix_shell_setup" \
spwhitt/nix-zsh-completions \
Aloxaf/fzf-tab \
MichaelAquilina/zsh-auto-notify \
hlissner/zsh-autopair
autoload -Uz compinit && compinit
# Autocompletion
# The following lines were added by compinstall
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _complete _ignored _correct
zstyle ':completion:*' format '%d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' ignore-parents parent
zstyle ':completion:*' insert-unambiguous true
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{[:lower:]}={[:upper:]} m:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' max-errors 2 numeric
zstyle ':completion:*' menu select=7
zstyle ':completion:*' original true
zstyle ':completion:*' preserve-prefix '//[^/]##/'
zstyle ':completion:*' select-prompt %S current selection at %p%s
zstyle ':completion:*' squeeze-slashes true
zstyle ':completion:*' verbose true
zstyle :compinstall filename '/home/user/.zshrc'
# End of lines added by compinstall
# autoload -U colors && colors TODO is this necessary?
autoload edit-command-line # Prevent weird things from happening with entering text on the command line
zle -N edit-command-line
setopt COMPLETE_ALIASES # autocompletion of command line switches for aliases
kitty + complete setup zsh | . /dev/stdin # Completion for kitty
_ZD_FZF_OPTS="-m --preview 'bat --style=numbers --color=always {} 2>/dev/null'"
# zoxide (must be called after compinit)
eval "$(zoxide init zsh --cmd j)"
# nvm (normally in `init-nvm.sh`, but I prefer to be explicit)
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"
source /usr/share/nvm/nvm.sh
source /usr/share/nvm/install-nvm-exec
#source /usr/share/nvm/bash_completion we use zsh
# pyenv
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(direnv hook zsh)"
# rbenv
eval "$(rbenv init - zsh)"
export CARGO_MANIFEST_DIR="/usr/bin/corelib/"
# opam configuration
[[ ! -r /home/user/.opam/opam-init/init.zsh ]] || source /home/user/.opam/opam-init/init.zsh > /dev/null 2> /dev/null