forked from MikeMcQuaid/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
zprofile.sh
53 lines (42 loc) · 1.51 KB
/
zprofile.sh
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
# load shared shell configuration
source ~/.shprofile
# Enable completions
autoload -U compinit && compinit
if which brew &>/dev/null
then
[ -w "$HOMEBREW_PREFIX/bin/brew" ] && \
[ ! -f "$HOMEBREW_PREFIX/share/zsh/site-functions/_brew" ] && \
mkdir -p "$HOMEBREW_PREFIX/share/zsh/site-functions" &>/dev/null && \
ln -s "$HOMEBREW_PREFIX/Library/Contributions/brew_zsh_completion.zsh" \
"$HOMEBREW_PREFIX/share/zsh/site-functions/_brew"
FPATH="$HOMEBREW_PREFIX/share/zsh/site-functions:$FPATH"
fi
# 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
# Expand parameters, commands and aritmatic in prompts
setopt prompt_subst
# Colorful prompt with Git and Subversion branch
autoload -U colors && colors
git_branch() {
GIT_BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null) || return
[ -n "$GIT_BRANCH" ] && echo "($GIT_BRANCH) "
}
if [ "$USER" = "root" ]
then
export PROMPT='%{$fg_bold[magenta]%}%m %{$fg_bold[blue]%}# %b%f'
elif [ -n "${SSH_CONNECTION}" ]
then
export PROMPT='%{$fg_bold[cyan]%}%m %{$fg_bold[blue]%}# %b%f'
else
export PROMPT='%{$fg_bold[green]%}%m %{$fg_bold[blue]%}# %b%f'
fi
export RPROMPT='%{$fg_bold[red]%}$(git_branch)%b[%{$fg_bold[blue]%}%~%b%f]'
# more macOS/Bash-like word jumps
export WORDCHARS=""