From a4766e5f1569990575300734ac30a4f98ac1e8a3 Mon Sep 17 00:00:00 2001 From: Andrew Hodges Date: Sun, 29 May 2011 09:32:44 -0400 Subject: [PATCH 1/3] Aliases Modify directory listing aliases to make more sense. Remove conflicting helper function (mcd conflicts with mtools). --- lib/aliases.zsh | 3 ++- lib/directories.zsh | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/aliases.zsh b/lib/aliases.zsh index b47de5bde..8c510e0ef 100644 --- a/lib/aliases.zsh +++ b/lib/aliases.zsh @@ -16,8 +16,9 @@ alias history='fc -l 1' # List direcory contents alias lsa='ls -lah' -alias l='ls -la' +alias l='ls -lA1' alias ll='ls -l' +alias la='ls -lA' alias sl=ls # often screw this up alias afind='ack-grep -il' diff --git a/lib/directories.zsh b/lib/directories.zsh index bb114f615..7f74d924f 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -37,8 +37,3 @@ cd () { alias md='mkdir -p' alias rd=rmdir alias d='dirs -v' - -# mkdir & cd to it -function mcd() { - mkdir -p "$1" && cd "$1"; -} \ No newline at end of file From 77f3689b821064155e807769e9dbed5fcd2bcdff Mon Sep 17 00:00:00 2001 From: Andrew Hodges Date: Sun, 29 May 2011 12:22:00 -0400 Subject: [PATCH 2/3] Git Current Remote Make function definitions consistent. Copy current_branch from plugin and rename to git_current_branch. Exchange usage of current_branch with git_current_branch. Add helper function to get the current branch's remote. Update git_prompts_ahead to use git_current_remote instead of origin. Add git_prompt_behind. --- lib/git.zsh | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index ce4de5598..4697a0f1a 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -5,7 +5,7 @@ function git_prompt_info() { } # Checks if working tree is dirty -parse_git_dirty() { +function parse_git_dirty() { if [[ -n $(git status -s 2> /dev/null) ]]; then echo "$ZSH_THEME_GIT_PROMPT_DIRTY" else @@ -15,11 +15,17 @@ parse_git_dirty() { # Checks if there are commits ahead from remote function git_prompt_ahead() { - if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then + if $(echo "$(git log $(git_current_remote)/$(git_current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then echo "$ZSH_THEME_GIT_PROMPT_AHEAD" fi } +function git_prompt_behind() { + if $(echo "$(git log HEAD..$(git_current_remote)/$(git_current_branch) 2> /dev/null)" | grep '^commit' &> /dev/null); then + echo "$ZSH_THEME_GIT_PROMPT_BEHIND" + fi +} + # Formats prompt string for current git commit short SHA function git_prompt_short_sha() { SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" @@ -31,7 +37,7 @@ function git_prompt_long_sha() { } # Get the status of the working tree -git_prompt_status() { +function git_prompt_status() { INDEX=$(git status --porcelain 2> /dev/null) STATUS="" if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then @@ -60,3 +66,17 @@ git_prompt_status() { fi echo $STATUS } + +function git_current_branch() { + ref=$(git symbolic-ref HEAD 2> /dev/null) || return + echo ${ref#refs/heads/} +} + +function git_current_remote() { + remote=$(git config --get "branch.$(git_current_branch).remote") + if [ -z "$remote" ]; then + echo 'origin' + else + echo "$remote" + fi +} From 6c9fa1a13c3c64577c8909704f6d7b9090215178 Mon Sep 17 00:00:00 2001 From: Andrew Hodges Date: Sun, 29 May 2011 16:12:14 -0400 Subject: [PATCH 3/3] Succumbed to Peer Pressure Change git_current_branch to current_branch. --- lib/git.zsh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index 4697a0f1a..a5a7d2e84 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -15,13 +15,13 @@ function parse_git_dirty() { # Checks if there are commits ahead from remote function git_prompt_ahead() { - if $(echo "$(git log $(git_current_remote)/$(git_current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then + if $(echo "$(git log $(git_current_remote)/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then echo "$ZSH_THEME_GIT_PROMPT_AHEAD" fi } function git_prompt_behind() { - if $(echo "$(git log HEAD..$(git_current_remote)/$(git_current_branch) 2> /dev/null)" | grep '^commit' &> /dev/null); then + if $(echo "$(git log HEAD..$(git_current_remote)/$(current_branch) 2> /dev/null)" | grep '^commit' &> /dev/null); then echo "$ZSH_THEME_GIT_PROMPT_BEHIND" fi } @@ -67,13 +67,8 @@ function git_prompt_status() { echo $STATUS } -function git_current_branch() { - ref=$(git symbolic-ref HEAD 2> /dev/null) || return - echo ${ref#refs/heads/} -} - function git_current_remote() { - remote=$(git config --get "branch.$(git_current_branch).remote") + remote=$(git config --get "branch.$(current_branch).remote") if [ -z "$remote" ]; then echo 'origin' else