Skip to content

Loading…

auto-correction mayhem fix for git #1831

Closed
wants to merge 3 commits into from

2 participants

@ChaseVoid

added new alias for 'git status' and 'git config' to prevent zsh autocorrect

@amaltson

Now that oh-my-zsh turns off the autocorrect (AFAIR), is this patch still required?

@ChaseVoid

No. With the latest updates this is no longer needed. I'll close the request.

@ChaseVoid ChaseVoid closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 18, 2013
  1. @ChaseVoid

    Update correction.zsh

    ChaseVoid committed
    added new alias for 'git status' and 'git config' to prevent zsh autocorrect
Commits on Jun 29, 2013
  1. @ChaseVoid
  2. @ChaseVoid
Showing with 5 additions and 59 deletions.
  1. +2 −0 lib/correction.zsh
  2. +3 −59 themes/agnoster.zsh-theme
View
2 lib/correction.zsh
@@ -11,4 +11,6 @@ else
alias ebuild='nocorrect ebuild'
alias hpodder='nocorrect hpodder'
alias sudo='nocorrect sudo'
+ alias git status='nocorrect git status'
+ alias git config='nocorrect git config'
fi
View
62 themes/agnoster.zsh-theme
@@ -26,7 +26,7 @@
# A few utility functions to make it easy and re-usable to draw segmented prompts
CURRENT_BG='NONE'
-SEGMENT_SEPARATOR=''
+SEGMENT_SEPARATOR=''
# Begin a segment
# Takes two arguments, background and foreground. Both can be omitted,
@@ -71,6 +71,7 @@ prompt_context() {
prompt_git() {
local ref dirty
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
+ ZSH_THEME_GIT_PROMPT_DIRTY='±'
dirty=$(parse_git_dirty)
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="$(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
if [[ -n $dirty ]]; then
@@ -78,70 +79,15 @@ prompt_git() {
else
prompt_segment green black
fi
-
- setopt promptsubst
- autoload -Uz vcs_info
-
- zstyle ':vcs_info:*' enable git
- zstyle ':vcs_info:*' get-revision true
- zstyle ':vcs_info:*' check-for-changes true
- zstyle ':vcs_info:*' stagedstr ''
- zstyle ':vcs_info:git:*' unstagedstr ''
- zstyle ':vcs_info:*' formats ' %u%c'
- zstyle ':vcs_info:*' actionformats '%u%c'
- vcs_info
- echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_}"
+ echo -n "${ref/refs\/heads\//⭠ }$dirty"
fi
}
-prompt_hg() {
- local rev status
- if $(hg id >/dev/null 2>&1); then
- if $(hg prompt >/dev/null 2>&1); then
- if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
- # if files are not added
- prompt_segment red white
- st='±'
- elif [[ -n $(hg prompt "{status|modified}") ]]; then
- # if any modification
- prompt_segment yellow black
- st='±'
- else
- # if working copy is clean
- prompt_segment green black
- fi
- echo -n $(hg prompt " {rev}@{branch}") $st
- else
- st=""
- rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
- branch=$(hg id -b 2>/dev/null)
- if `hg st | grep -Eq "^\?"`; then
- prompt_segment red black
- st='±'
- elif `hg st | grep -Eq "^(M|A)"`; then
- prompt_segment yellow black
- st='±'
- else
- prompt_segment green black
- fi
- echo -n "$rev@$branch" $st
- fi
- fi
-}
-
# Dir: current working directory
prompt_dir() {
prompt_segment blue black '%~'
}
-# Virtualenv: current working virtualenv
-prompt_virtualenv() {
- local virtualenv_path="$VIRTUAL_ENV"
- if [[ -n $virtualenv_path ]]; then
- prompt_segment blue black "(`basename $virtualenv_path`)"
- fi
-}
-
# Status:
# - was there an error
# - am I root
@@ -160,11 +106,9 @@ prompt_status() {
build_prompt() {
RETVAL=$?
prompt_status
- prompt_virtualenv
prompt_context
prompt_dir
prompt_git
- prompt_hg
prompt_end
}
Something went wrong with that request. Please try again.