Browse Source

Cleaned up misc features that I've started to find annoying

pull/2/head
Josh Wolfe 5 years ago
parent
commit
0bd3ab3066
  1. 92
      zsh/.zsh/git-prompt.zsh
  2. 13
      zsh/.zshrc

92
zsh/.zsh/git-prompt.zsh

@ -1,92 +0,0 @@ @@ -1,92 +0,0 @@
function in_git_repos() {
test "`git rev-parse --is-inside-work-tree 2>/dev/null`" = "true"
}
function git_current_branch() {
if in_git_repos; then
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
echo ${ref#refs/heads/}
fi
}
function git_status_is_clean() {
if in_git_repos; then
local lines=$(git status --porcelain | egrep -v '^\?\? ' | wc -l)
test $lines = 0
fi
}
function git_unknown_files() {
if in_git_repos; then
local lines=$(git status --porcelain | egrep '^\?\? ' | wc -l)
test $lines = 0
fi
}
function git_stash_is_clean() {
if in_git_repos; then
local lines=$(git stash list | wc -l)
test $lines = 0
fi
}
function git_no_branches() {
if in_git_repos; then
local lines=$(git branch | wc -l)
test $lines = 1
fi
}
function git_single_remote() {
if in_git_repos; then
local lines=$(git remote | wc -l)
test $lines -le 1
fi
}
function git_no_remote() {
if in_git_repos; then
local lines=$(git remote | wc -l)
test $lines = 0
fi
}
function git_branch_is_pushed() {
if in_git_repos; then
if git branch -r | grep "origin/master" >/dev/null 2>&1; then
git_no_remote || git diff-tree --quiet origin/master heads/master
fi
fi
}
#-----------------------------------------------------------------------------
function git_prompt_precmd() {
local GITINFO=""
if [ ! -z `git_current_branch` ]; then
GITINFO=" "
if ! git_status_is_clean; then
GITINFO="$GITINFO*"
fi
if ! git_unknown_files; then
GITINFO="${GITINFO}?"
fi
if ! git_branch_is_pushed; then
GITINFO="$GITINFO"
fi
if ! git_stash_is_clean; then
GITINFO="$GITINFO"
fi
if ! git_no_branches; then
GITINFO="$GITINFO"
fi
if ! git_single_remote; then
GITINFO="$GITINFO®"
fi
GITINFO="$GITINFO "
fi
echo $GITINFO
}

13
zsh/.zshrc

@ -11,7 +11,7 @@ autoload -U colors && colors @@ -11,7 +11,7 @@ autoload -U colors && colors
export CLICOLOR=1
# awesome cd movements from zshkit
setopt autocd autopushd pushdminus pushdsilent pushdtohome cdablevars
setopt autopushd pushdminus pushdsilent pushdtohome
DIRSTACKSIZE=5
# Enable extended globbing
@ -160,20 +160,11 @@ _newline=$'\n' @@ -160,20 +160,11 @@ _newline=$'\n'
_lineup=$'\e[1A'
_linedown=$'\e[1B'
# * There are uncommitted changes.
# ? There are files git doesn't know about.
# ➚ There are commits that haven't been pushed yet.
# ☰ There are stashed files.
# ⌥ There are branches other than master.
# ® There are remote repositories other than origin configured.
source ~/.zsh/git-prompt.zsh
function preexec() {
echo
}
function precmd() {
echo
PSVAR=`git_prompt_precmd`
}
PROMPT="%F{red}%n%F{white}@%F{green}%m %F{blue}%~ ${_newline}%F{white}$ "
@ -194,4 +185,4 @@ fi @@ -194,4 +185,4 @@ fi
# added by travis gem
[ -f /home/wolfe/.travis/travis.sh ] && source /home/wolfe/.travis/travis.sh
[ -f ~/.travis/travis.sh ] && source ~/.travis/travis.sh

Loading…
Cancel
Save