mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-29 00:10:12 +08:00
3c87d48362
(via git status -s, benchmarked)
38 lines
947 B
Bash
38 lines
947 B
Bash
# get the name of the branch we are on
|
|
function git_prompt_info() {
|
|
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
|
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
|
}
|
|
|
|
parse_git_dirty () {
|
|
if [[ -n $(git status -s 2> /dev/null) ]]; then
|
|
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
|
else
|
|
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
|
|
fi
|
|
}
|
|
|
|
#
|
|
# Will return the current branch name
|
|
# Usage example: git pull origin $(current_branch)
|
|
#
|
|
function current_branch() {
|
|
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
|
echo ${ref#refs/heads/}
|
|
}
|
|
|
|
# Aliases
|
|
alias g='git'
|
|
alias gst='git status'
|
|
alias gl='git pull'
|
|
alias gup='git fetch && git rebase'
|
|
alias gp='git push'
|
|
alias gd='git diff | mate'
|
|
alias gdv='git diff -w "$@" | vim -R -'
|
|
alias gc='git commit -v'
|
|
alias gca='git commit -v -a'
|
|
alias gb='git branch'
|
|
alias gba='git branch -a'
|
|
alias gcount='git shortlog -sn'
|
|
alias gcp='git cherry-pick'
|