forked from fabriziocucci/git-bash-for-mac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-zsh-for-mac.sh
31 lines (25 loc) · 1.06 KB
/
git-zsh-for-mac.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
#!/bin/bash
# see https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.zsh
# see https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
# see see https://stackoverflow.com/questions/28028740/git-tab-completion-in-zsh-throwing-errors
zstyle ':completion:*:*:git:*' script ~/.zsh/git-completion.bash
fpath=(~/.zsh $fpath)
# see https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
source ~/.zsh/git-prompt.sh
# color support for prompt
# see https://stackoverflow.com/questions/689765/how-can-i-change-the-color-of-my-prompt-in-zsh-different-from-normal-text
autoload -U colors && colors
DEFAULT="%{$fg[black]%}"
GREEN="%{$fg[green]%}"
YELLOW="%{$fg[yellow]%}"
CYAN="%{$fg[cyan]%}"
# prompt format
# see https://wiki.gentoo.org/wiki/Zsh/Guide
USERNAME='%n'
MACHINE='%m'
WORKDIR='%~'
NEWLINE=$'\n'
GITBRANCH=$(__git_ps1 " (%s)")
setopt PROMPT_SUBST ; PS1='${GREEN}${USERNAME}@${MACHINE}${YELLOW} ${WORKDIR}${CYAN}${GITBRANCH}${DEFAULT}${NEWLINE}\$ '
# reload
autoload -Uz compinit && compinit