-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
zshrc
137 lines (120 loc) · 3.97 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
# The following lines were added by compinstall
fpath=($HOME/.zcomp $fpath)
zstyle ':completion:*' completer _expand _complete _ignored _approximate
zstyle ':completion:*' special-dirs true
zstyle ':completion:*' menu select
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle :compinstall filename '/home/pkrones/.zshrc'
autoload -Uz compinit
compinit
# End of lines added by compinstall
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=10000
setopt sharehistory
setopt appendhistory
setopt histignoredups
unsetopt autocd beep
unsetopt BASH_AUTO_LIST
bindkey -v
# End of lines configured by zsh-newuser-install
# Setup editor command editing
autoload edit-command-line
zle -N edit-command-line
bindkey -M vicmd ' ' edit-command-line
[[ $- != *i* ]] && return
PS1='[%B%F{red}%n%F{white}%b@%B%F{blue}%M%b%F{white}▶ %1~]$ '
export EDITOR=nvim
if command -v tmux >/dev/null 2>&1; then
# when quitting tmux, try to attach
while test -z $TMUX; do
tmux attach || break
done
# if no session is started, start a new session
[[ -z "$TMUX" ]] && tmux
fi
# Aliases
## Make aliases work with sudo (http://askubuntu.com/questions/22037/aliases-not-available-when-using-sudo)
alias sudo='sudo '
## cd.. == cd ..
alias cd..='cd ..'
## Color the ls output
alias ls='ls --color=auto'
## Color the diff output
alias diff='diff --color=auto'
## Color the grep output
alias grep='grep --color=auto'
## Show hidden files
alias la='ls -a'
## Use a listing format
alias l='ls -l'
## Use a long listing format
alias ll='ls -la'
## Run nvim as sudo
command -v nvim >/dev/null 2>&1 && alias svim='sudo nvim' || alias svim='sudo vim'
## Run nvim in pipenv
command -v nvim >/dev/null 2>&1 && alias pvim='pipenv run nvim' || alias pvim='pipenv run vim'
## Git status
alias gits='git status'
## Tmux easy session attach
command -v tmux >/dev/null 2>&1 && alias tmuxa='tmux attach -t'
# watch a list of files/dirs and execute a command on change
# usage: `watch -f dir_name -c cmd`
watch() {
while [[ "$#" -gt 0 ]]
do
case $1 in
-h|--help)
echo "usage: watch -f dir_name -c cmd"
return
;;
-f|--file)
local FILE="$2"
;;
-c|--command)
shift
break
;;
esac
shift
done
while inotifywait -e modify -r $FILE; do
$@
done
}
command -v nvim >/dev/null 2>&1 && alias vim=nvim
command -v fuck >/dev/null 2>&1 && eval $(thefuck --alias)
alias rustdown='for tc in $(rustup toolchain list | grep "nightly-20*"); do rustup toolchain uninstall $tc; done'
command -v pyenv >/dev/null 2>&1 && export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null 2>&1 && export PATH="$PYENV_ROOT/bin:$PATH"
command -v pyenv >/dev/null 2>&1 && eval "$(pyenv init -)"
command -v luarocks >/dev/null 2>&1 && export PATH="$(luarocks config home_tree)/bin:$PATH"
autoload zkbd
function zkbd_file() {
[[ -f ~/.zkbd/${TERM}-${VENDOR}-${OSTYPE} ]] && printf '%s' ~/".zkbd/${TERM}-${VENDOR}-${OSTYPE}" && return 0
[[ -f ~/.zkbd/${TERM}-${DISPLAY} ]] && printf '%s' ~/".zkbd/${TERM}-${DISPLAY}" && return 0
return 1
}
[[ ! -d ~/.zkbd ]] && mkdir ~/.zkbd
keyfile=$(zkbd_file)
ret=$?
if [[ ${ret} -ne 0 ]]; then
zkbd
keyfile=$(zkbd_file)
ret=$?
fi
if [[ ${ret} -eq 0 ]] ; then
source "${keyfile}"
else
printf 'Failed to setup keys using zkbd.\n'
fi
unfunction zkbd_file; unset keyfile ret
[[ -n "$key[Home]" ]] && bindkey "$key[Home]" beginning-of-line
[[ -n "$key[End]" ]] && bindkey "$key[End]" end-of-line
[[ -n "$key[Insert]" ]] && bindkey "$key[Insert]" overwrite-mode
[[ -n "$key[Backspace]" ]] && bindkey "$key[Backspace]" backward-delete-char
[[ -n "$key[Delete]" ]] && bindkey "$key[Delete]" delete-char
[[ -f ~/.fzf.zsh ]] && source ~/.fzf.zsh
command -v zoxide >/dev/null 2>&1 && eval "$(zoxide init --cmd cd zsh)"
command -v plz >/dev/null 2>&1 && source <(plz --completion_script)