forked from MikeMcQuaid/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzshrc
executable file
·91 lines (70 loc) · 2.35 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
# load shared shell configuration
source ~/.shrc
# Enable advanced completion
autoload -U compinit && compinit
# Enable regex moving
autoload -U zmv
# Style ZSH output
zstyle ':completion:*:descriptions' format '%U%B%F{red}%d%f%b%u'
zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b'
# Case insensitive completion
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
# Case insensitive globbing
setopt no_case_glob
# Change to directory by just entering name
setopt auto_cd
# Don't show duplicate history entires
setopt hist_find_no_dups
# Remove unnecessary blanks from history
setopt hist_reduce_blanks
# Share history between instances
setopt share_history
# Don't hang up background jobs
setopt no_hup
# Expand parameters, commands and aritmatic in prompts
setopt prompt_subst
# Colorful prompt with Git and Subversion branch
autoload -U colors && colors
git_branch() {
BRANCH_REFS=$(git symbolic-ref HEAD 2>/dev/null) || return
echo "(${BRANCH_REFS#refs/heads/}) "
}
svn_branch() {
[ -d .svn ] || return
SVN_INFO=$(svn info 2>/dev/null) || return
SVN_BRANCH=$(echo $SVN_INFO | grep URL: | grep -oe '\(trunk\|branches/[^/]\+\|tags/[^/]\+\)')
[ -n "$SVN_BRANCH" ] || return
# Display tags intentionally so we don't write to them by mistake
echo "(${SVN_BRANCH#branches/}) "
}
if [[ $(whoami) == "root" ]]
then
PROMPT='%{$fg_bold[magenta]%}%m %{$fg_bold[blue]%}# %b%f'
elif [ -n "${SSH_CLIENT}" ]
then
PROMPT='%{$fg_bold[cyan]%}%m %{$fg_bold[blue]%}# %b%f'
else
PROMPT='%{$fg_bold[green]%}%m %{$fg_bold[blue]%}# %b%f'
fi
RPROMPT='%{$fg_bold[red]%}$(git_branch)%{$fg_bold[yellow]%}$(svn_branch)%b[%{$fg_bold[blue]%}%~%b%f]'
# History
export HISTSIZE=2000
export HISTFILE=~/.zsh_history
export SAVEHIST=$HISTSIZE
# use emacs bindings even with vim as EDITOR
bindkey -e
# fix backspace on Debian
bindkey "^?" backward-delete-char
# allow the use of the Delete/Insert keys
bindkey "\e[3~" delete-char
bindkey "\e[2~" quoted-insert
# alternate mappings for "page up" and "page down" to search the history
bindkey "^u" history-beginning-search-backward
bindkey "^v" history-beginning-search-forward
# mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
bindkey "\e[1;5C" forward-word
bindkey "\e[1;5D" backward-word
bindkey "\e[5C" forward-word
bindkey "\e[5D" backward-word
bindkey "\e\e[C" forward-word
bindkey "\e\e[D" backward-word