-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
144 lines (115 loc) · 3.86 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
# Completion options from oh-my-zsh:
unsetopt menu_complete
setopt auto_menu
setopt complete_in_word
setopt always_to_end
# Fire up completion
autoload -U compinit
compinit
# History options from oh-my-zsh:
if [ -z $HISTFILE ]; then
HISTFILE=$HOME/.zsh_history
fi
HISTSIZE=1000000000
SAVEHIST=$HISTSIZE
setopt extended_history
setopt hist_ignore_dups # Don't record sequential duplicates.
#setopt hist_ignore_all_dups # Axe any previous instances of a command.
setopt hist_expire_dups_first # Remove duplicates before unique commands.
setopt hist_ignore_space # Don't record entries starting with a space.
setopt hist_reduce_blanks # Strip extra whitespace.
setopt hist_verify
setopt share_history # share history between sessions
bindkey -e
# Key bindings from the Arch wiki:
# create a zkbd compatible hash;
# to add other keys to this hash, see: man 5 terminfo
typeset -A key
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
# setup key accordingly
[[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode
[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char
[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-history
[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-history
[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char
bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
# This implements a bash-style backward-kill-word.
# To use,
# zle -N bash-backward-kill-word
# bindkey '...' bash-backward-kill-word
function bash-backward-kill-word {
local WORDCHARS=''
zle .backward-kill-word
}
zle -N bash-backward-kill-word
bindkey '^W' bash-backward-kill-word
# Yay colors
autoload -U colors && colors
alias grep="grep --color=auto"
alias ls="ls --color=auto"
# Useful commands
alias dmap="tree --du -h --dirsfirst --sort=size"
alias lss="ls -lShr"
alias lst="ls -lthr"
alias el="exa -lh"
alias es="exa -lhs size"
alias ed="exa -lhs date"
alias e1="exa -1"
# Patience diff is best diff
alias pdiff=git diff --patience --no-index
# Self-deprecating humor
alias :w="echo E_NOTVIM"
alias :wq="echo E_I_AM_A_SHELL"
alias :q="echo In Russia, shell quits you!"
alias :qa="echo No escape"
# ...
alias rot13="tr '[A-Za-z]' '[N-ZA-Mn-za-m]'"
# Helps pinentry behave when unlocking GPG keys
export GPG_TTY=$(tty)
# Stop libstdc++ misadventures:
# https://www.zerotier.com/blog/2017-05-05-theleak.shtml
# https://gcc.gnu.org/onlinedocs/libstdc++/manual/memory.html
export GLIBCXX_FORCE_NEW=y
# Neovim!
if type nvim >/dev/null; then
export EDITOR=nvim
elif type vim >/dev/null; then
export EDITOR=vim
elif type vi >/dev/null; then
export EDITOR=vi
fi
# Saves some stat() calls, FWIW:
# https://blog.packagecloud.io/eng/2017/02/21/set-environment-variable-save-thousands-of-system-calls/
export TZ=":/etc/localtime"
# LESS Options
export LESS=-x4RSX
# Set up our prompt
setopt prompt_subst
setopt prompt_percent
export PATH=$PATH:~/src/promptoglyph/build
if promptoglyph-vcs --version >/dev/null; then
export PS1='%F{red}%(?..[%?] )%f%F{green}%~%f$(promptoglyph-vcs --zsh --prefix " [") $ '
else
export PS1='%F{red}%(?..[%?] )%f%F{green}%~%f $ '
fi
export RPS1=''
# warm fuzzies
if [ -n "${commands[fzf-share]}" ]; then
source "$(fzf-share)/key-bindings.zsh"
source "$(fzf-share)/completion.zsh"
fi
# bat (syntax-highlighting cat) - white text on light term is bad, mmmk?
export BAT_THEME=ansi
# ditto for fd (colorized find)
export LS_COLORS=""
# Machine-specific nonsense
[[ -f ~/.zshrc-machine ]] && source ~/.zshrc-machine
# Clear error code so I'm not greeted with a red "1" at home
true