-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
135 lines (118 loc) · 3.98 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
# Trap for tmux
if command -v tmux>/dev/null; then
[[ ! $TERM =~ screen ]] && [ -z $TMUX ] && exec tmux
fi
# Variables
export ZSHRC="~/.zshrc"
export VIMRC="~/.vimrc"
export EDITOR="vim"
# General Options
setopt auto_cd # if a command cannot be executed, perform cd command
setopt pushd_to_home # pushd without arguments becomes pushd $home
#setopt vi # use vi keymappings
setopt no_beep # disable beeping
unsetopt flow_control # disable ^s from stopping terminal
# Git Prompt - now done asynchronously
#ZSH_THEME_GIT_PROMPT_CACHE="Y"
#source ~/.zsh/git-prompt/zshrc.sh
# Prompt
autoload -U colors && colors
setopt prompt_subst # variable substitution in the prompt
# %B - begin bold
# %b - end bold
# %n - username
# %m - machine name
# %# - prompt symbol (becomes % for non-privileged user)
PROMPT='%B%(0?..[%?] )\
%{$fg[red]%}%n@%m \
%{$fg[blue]%}%.%b\
%{$reset_color%} \
%B%#%b '
RPROMPT_PREV=''
RPROMPT=''
mkdir -p "$TMPPREFIX"
function precmd {
function build_rprompt {
source ~/.zsh/git-prompt/zshrc.sh
sleep 1
echo -n "$(git_super_status)" > "$TMPPREFIX/rprompt.$$"
kill -s USR2 $$
}
RPROMPT="*$RPROMPT_PREV"
build_rprompt &!
}
function TRAPUSR2 {
RPROMPT=$(cat "$TMPPREFIX/rprompt.$$")
RPROMPT_PREV="$RPROMPT"
zle && zle reset-prompt
}
# History
export HISTSIZE=2000
export SAVEHIST=2000
export HISTFILE=$HOME/.zsh_history
setopt hist_ignore_all_dups # ignore adjacent duplicate entries
setopt hist_ignore_space # don't save command if preceded by a space
setopt hist_reduce_blanks # remove extra whitespace from commands saved to history file
setopt INC_APPEND_HISTORY # history is continuously appended
# Completion
autoload -U compinit
compinit
setopt always_to_end # completion moves cursor to end of word
setopt list_ambiguous # automatically show hints for ambiguous completion
setopt auto_list #
setopt list_types # add identifying file type marks to the suggestions
setopt auto_menu # show a menu if tab is pressed repeatedly
# Smarter completion
setopt auto_param_keys
setopt auto_param_slash
setopt auto_remove_slash
# Expansion
setopt rm_star_wait # using rm with a glob has a safe wait
setopt bad_pattern # show an error if a glob is badly formed
setopt numeric_glob_sort # sort filenames containing numbers numerically
setopt rc_expand_param # 'foo${xx}bar', where xx is 'a b c', expands to 'fooabar foobbar foocbar'
# Graveyard
# This was over-eager in finding mistakes (ex: mv hello1.txt hello2.txt):
#setopt correctall
# This makes it difficult to access the most recently entries in the history
# when rapidly switching between terminals:
#setopt share_history # history is shared across terminals
# Grep color
# This turns on color output for grep.
alias grep="grep --color=auto"
# Aliases
alias ls='ls --color=auto --classify' # Color is disabled when piping
alias zshrc="$EDITOR $ZSHRC && source $ZSHRC" # reloads .zshrc after editing
alias vimrc="$EDITOR $VIMRC"
alias g='git' # .gitconfig contains additional aliases
alias ws='python -m SimpleHTTPServer' # web server
alias disableautomount='gsettings set org.gnome.desktop.media-handling automount false'
alias enableautomount='gsettings set org.gnome.desktop.media-handling automount true'
# Sudo, but keep path env variable
function sudop() {
sudo "PATH=$PATH" sh -c "$*"
}
# I have some private configurations I like to keep secret. ;)
if [ -n "$PRIVATE" ]; then
if [ -e "$PRIVATE" ]; then
source "$PRIVATE"
else
echo 'Error: could not source private configurations'
fi
fi
# Go
# I put all my go installations in $HOME/go/root. List them with golist. Switch
# to a different installation with gouse.
golist() {
dir "$HOME/go/root"
}
gouse() {
export GOROOT=$HOME/go/root/$1
export PATH=$GOROOT/bin:$PATH
go version
}
export PATH=$PATH:$HOME/go/bin
gouse go1.12.5
# Go projects I often contribute to.
UROOT=$HOME/go/src/github.com/u-root/u-root
FIANO=$HOME/go/src/github.com/linuxboot/fiano