forked from seagle0128/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
143 lines (123 loc) · 4.96 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
# Zsh configuration
ANTIGEN=$HOME/.antigen
DOTFILES=$HOME/.dotfiles
# Configure Antigen
declare -a ANTIGEN_CHECK_FILES
ANTIGEN_CHECK_FILES=($HOME/.zshrc $HOME/.zshrc.local)
# Load Antigen
if [[ $OSTYPE == darwin* ]]; then
source /usr/local/share/antigen/antigen.zsh
else
if command -v apt-get >/dev/null 2>&1; then
source /usr/share/zsh-antigen/antigen.zsh
elif command -v yaourt >/dev/null 2>&1; then
source /usr/share/zsh/share/antigen.zsh
else
source $ANTIGEN/antigen.zsh
fi
fi
# Load the oh-my-zsh's library
antigen use oh-my-zsh
# Bundles from the default repo (robbyrussell's oh-my-zsh)
antigen bundle common-aliases
antigen bundle git
antigen bundle colored-man-pages
antigen bundle extract
antigen bundle sudo
antigen bundle z
# Misc bundles.
command -v python >/dev/null 2>&1 && antigen bundle djui/alias-tips
[[ $OSTYPE != cygwin* ]] && antigen bundle andrewferrier/fzf-z
if command -v fdfind >/dev/null 2>&1; then
alias fd='fdfind';
fi
# OS bundles
if [[ $OSTYPE == darwin* ]]; then
antigen bundle osx
if command -v brew >/dev/null 2>&1; then
export HOMEBREW_INSTALL_CLEANUP=1
alias bu='brew update && brew upgrade'
alias bcu='brew cu --all --yes --cleanup'
alias bua='bu && bcu'
fi
elif [[ $OSTYPE == linux* ]]; then
if command -v apt-get >/dev/null 2>&1; then
antigen bundle ubuntu
alias agua='aguu -y && agar -y && aga -y'
alias kclean+='sudo aptitude remove -P "?and(~i~nlinux-(ima|hea),\
?not(?or(~n`uname -r | cut -d'\''-'\'' -f-2`,\
~nlinux-generic,\
~n(linux-(virtual|headers-virtual|headers-generic|image-virtual|image-generic|image-`dpkg --print-architecture`)))))"'
elif command -v pacman >/dev/null 2>&1; then
antigen bundle archlinux
fi
fi
# antigen bundle zsh-users/zsh-completions
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zdharma/fast-syntax-highlighting
# antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-history-substring-search
antigen bundle hlissner/zsh-autopair
# Load the theme.
antigen theme ys # ys, dst, steeef, wedisagree, robbyrussell
# Local customizations, e.g. theme, plugins, aliases, etc.
[ -f $HOME/.zshrc.local ] && source $HOME/.zshrc.local
# Tell Antigen that you're done
antigen apply
# Completion enhancements
source $DOTFILES/completion.zsh
# Load FZF
if [[ $OSTYPE == cygwin* ]]; then
[ -f /etc/profile.d/fzf.zsh ] && source /etc/profile.d/fzf.zsh;
else
[ -f $HOME/.fzf.zsh ] && source $HOME/.fzf.zsh;
fi
if command -v rg >/dev/null 2>&1; then
export FZF_DEFAULT_COMMAND='rg --hidden --files'
elif command -v ag >/dev/null 2>&1; then
export FZF_DEFAULT_COMMAND='ag -U --hidden -g ""'
fi
export FZF_CTRL_T_OPTS="--preview '(highlight -O ansi -l {} 2> /dev/null || cat {} || tree -C {}) 2> /dev/null | head -200'"
export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview'"
export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200'"
#
# Aliases
#
unalias fd
# General
alias zshconf="$EDITOR $HOME/.zshrc; $EDITOR $HOME/.zshrc.local"
alias h='history'
alias c='clear'
alias rt='trash' # `brew install trash` or `npm install --global trash-cli`
alias gtr='git tag -d $(git tag) && git fetch --tags' # Refresh local tags from remote
if [[ $OSTYPE == darwin* ]]; then
command -v gls >/dev/null 2>&1 && alias ls='gls --color=tty --group-directories-first'
else
alias ls='ls --color=tty --group-directories-first'
fi
# Emacs
# alias emacs='emacsclient -a ""'
alias emacs-mini='emacs -Q --load ~/.emacs.d/init-mini.el'
alias e='emacsclient -n'
alias ec='emacsclient -c'
alias ef='emacsclient -n -c'
alias te='emacsclient -nw'
alias rmelc='rm -f $HOME/.emacs.d/lisp/*.elc'
alias rmtags='rm -f GTAGS; rm -f GRTAGS; rm -f GPATH; rm -f TAGS'
alias restart_emacs='emacsclient -e "(let ((last-nonmenu-event nil) (kill-emacs-query-functions nil)) (save-buffers-kill-emacs t))" && te'
# Upgrade
alias upgrade_repo='git pull --rebase --stat origin master'
alias upgrade_dotfiles='cd $DOTFILES && upgrade_repo; cd - >/dev/null'
alias upgrade_emacs='cd $HOME/.emacs.d && upgrade_repo; cd - >/dev/null'
alias upgrade_oh_my_tmux='cd $HOME/.tmux && upgrade_repo; cd - >/dev/null'
alias upgrade_env='upgrade_dotfiles && sh $DOTFILES/install.sh'
alias upgrade_pip="pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U"
if [[ $OSTYPE == darwin* ]]; then
command -v brew >/dev/null 2>&1 && alias upgrade_antigen='brew update antigen'
alias upgrade_brew_cask='$DOTFILES/install_brew_cask.sh'
elif [[ $OSTYPE == linux* ]]; then
# (( $+commands[apt-get] )) && apug -y antigen
alias upgrade_antigen='sudo curl -o /usr/share/zsh-antigen/antigen.zsh -sL git.io/antigen'
else
alias upgrade_antigen='curl -fsSL git.io/antigen > $ANTIGEN/antigen.zsh.tmp && mv $ANTIGEN/antigen.zsh.tmp $ANTIGEN/antigen.zsh'
fi