From 2d5412e99be6d9fab50169ad0cf290e022fc6e9b Mon Sep 17 00:00:00 2001 From: James Smith Date: Sat, 19 Mar 2011 17:50:24 -0700 Subject: Added new function git_remote_status to check if we are ahead, behind or diverged from the remote branch --- lib/git.zsh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib') diff --git a/lib/git.zsh b/lib/git.zsh index 8512de8a4..75367f877 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -4,6 +4,7 @@ function git_prompt_info() { echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" } +# get dirty status of the current working tree parse_git_dirty () { if [[ -n $(git status -s 2> /dev/null) ]]; then echo "$ZSH_THEME_GIT_PROMPT_DIRTY" @@ -12,6 +13,26 @@ parse_git_dirty () { fi } +# get the difference between the local and remote branches +git_remote_status() { + remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/} + if [[ -n ${remote} ]] ; then + ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) + behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) + + if [ $ahead -eq 0 ] && [ $behind -gt 0 ] + then + echo "$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE" + elif [ $ahead -gt 0 ] && [ $behind -eq 0 ] + then + echo "$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE" + elif [ $ahead -gt 0 ] && [ $behind -gt 0 ] + then + echo "$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE" + fi + fi +} + # get the status of the working tree git_prompt_status() { INDEX=$(git status --porcelain 2> /dev/null) -- cgit v1.2.3-70-g09d2 From 25adbe81a55664335e0166c202b8d8424a67c8aa Mon Sep 17 00:00:00 2001 From: Andrew Hodges Date: Sun, 29 May 2011 09:32:44 -0400 Subject: 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(-) (limited to 'lib') 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 -- cgit v1.2.3-70-g09d2 From 52733cb3bb0b1c85230c5c69e6c7231fb41c67fe Mon Sep 17 00:00:00 2001 From: Tadaya Tsuyukubo Date: Thu, 26 Jan 2012 15:20:08 -0800 Subject: prompt git-remove as deleted --- lib/git.zsh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/git.zsh b/lib/git.zsh index defa062c6..9c89c3664 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -54,6 +54,8 @@ git_prompt_status() { fi if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" + elif $(echo "$INDEX" | grep '^D ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" fi -- cgit v1.2.3-70-g09d2 From 8f89d4d5a5d584bae288d8111d83a6489a1369dc Mon Sep 17 00:00:00 2001 From: Darren Clark Date: Fri, 27 Jan 2012 01:20:06 -0700 Subject: Fixed Mac OS X Terminal.app related issue with extra newlines being printed out sometimes --- lib/termsupport.zsh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 221989502..6601cbcb8 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -6,6 +6,8 @@ function title { [ "$DISABLE_AUTO_TITLE" != "true" ] || return if [[ "$TERM" == screen* ]]; then print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars + elif [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then + print -Pn "\e]1;$1:q\a" #set icon (=tab) name (will override window name on broken terminal) elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then print -Pn "\e]2;$2:q\a" #set window name print -Pn "\e]1;$1:q\a" #set icon (=tab) name (will override window name on broken terminal) -- cgit v1.2.3-70-g09d2 From 75029cda2a52b656543ae5477328150654de8ccb Mon Sep 17 00:00:00 2001 From: Bjarki Ágúst Guðmundsson Date: Thu, 26 Jul 2012 17:54:15 +0000 Subject: Added a "please" alias for sudo --- lib/aliases.zsh | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/aliases.zsh b/lib/aliases.zsh index 0555be264..2eae3835a 100644 --- a/lib/aliases.zsh +++ b/lib/aliases.zsh @@ -8,6 +8,7 @@ alias -- -='cd -' # Super user alias _='sudo' +alias please='sudo' #alias g='grep -in' -- cgit v1.2.3-70-g09d2 From a3c2a2f6e8ff9db508070a905de056346386ef4f Mon Sep 17 00:00:00 2001 From: Caio Romão Date: Sun, 29 Jul 2012 20:18:26 +0200 Subject: Add branch status support to git_prompt_status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch makes git_prompt_status support three new status variables: - ZSH_THEME_GIT_PROMPT_AHEAD - ZSH_THEME_GIT_PROMPT_BEHIND - ZSH_THEME_GIT_PROMPT_DIVERGED With these extra variables it's easy to see (1) if you have commits in your local branch that weren't pushed to the remote (AHEAD), (2) if there are commits in the remote that you haven't merged/rebased yet (BEHIND) or (3) if you have local unpushed commits AND the remote has some commits you haven't merged yet (DIVERGED). Refer to the first line displayed on `git status -b --porcelain`. An example setup in a .zsh-theme file would be: ZSH_THEME_GIT_PROMPT_AHEAD="↑" ZSH_THEME_GIT_PROMPT_BEHIND="↓" ZSH_THEME_GIT_PROMPT_DIVERGED="↕" --- lib/git.zsh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/git.zsh b/lib/git.zsh index fb4ad8ca6..bca8bdc96 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -38,7 +38,7 @@ function git_prompt_long_sha() { # Get the status of the working tree git_prompt_status() { - INDEX=$(git status --porcelain 2> /dev/null) + INDEX=$(git status --porcelain -b 2> /dev/null) STATUS="" if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" @@ -66,6 +66,15 @@ git_prompt_status() { if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" fi + if $(echo "$INDEX" | grep '^## .*ahead' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS" + fi + if $(echo "$INDEX" | grep '^## .*behind' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS" + fi + if $(echo "$INDEX" | grep '^## .*diverged' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS" + fi echo $STATUS } -- cgit v1.2.3-70-g09d2 From 027fcccc9256aaf63e0d1b812069a1a0880f46fa Mon Sep 17 00:00:00 2001 From: Ted Vessenes Date: Tue, 31 Jul 2012 13:27:40 -0400 Subject: Make git use sha when branch name is missing. --- lib/git.zsh | 3 ++- plugins/git/git.plugin.zsh | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/git.zsh b/lib/git.zsh index fb4ad8ca6..af8b153d9 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -1,6 +1,7 @@ # get the name of the branch we are on function git_prompt_info() { - ref=$(git symbolic-ref HEAD 2> /dev/null) || return + ref=$(git symbolic-ref HEAD 2> /dev/null) || \ + ref=$(git rev-parse --short HEAD 2> /dev/null) || return echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" } diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index d3d3f702a..14237cebe 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -50,13 +50,14 @@ alias gsd='git svn dcommit' # Usage example: git pull origin $(current_branch) # function current_branch() { - ref=$(git symbolic-ref HEAD 2> /dev/null) || return + ref=$(git symbolic-ref HEAD 2> /dev/null) || \ + ref=$(git rev-parse --short HEAD 2> /dev/null) || return echo ${ref#refs/heads/} } function current_repository() { - - ref=$(git symbolic-ref HEAD 2> /dev/null) || return + ref=$(git symbolic-ref HEAD 2> /dev/null) || \ + ref=$(git rev-parse --short HEAD 2> /dev/null) || return echo $(git remote -v | cut -d':' -f 2) } -- cgit v1.2.3-70-g09d2 From 9af7f862999c458525d1a5c0f2470757ffe2f1dc Mon Sep 17 00:00:00 2001 From: Alexis Letessier Date: Wed, 1 Aug 2012 23:58:09 +0200 Subject: Correct variable used for global ssh known host completion --- lib/completion.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/completion.zsh b/lib/completion.zsh index f31e101d5..ba839a067 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -32,7 +32,7 @@ zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-dir cdpath=(.) # use /etc/hosts and known_hosts for hostname completion -[ -r /etc/ssh/ssh_known_hosts ] && _global_ssh_hosts=(${${${${(f)"$( Date: Sun, 5 Aug 2012 22:51:11 +0300 Subject: fix typo in cd-wrapper --- lib/directories.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/directories.zsh b/lib/directories.zsh index a787db9eb..1b92df6b3 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -26,9 +26,9 @@ cd () { elif [[ "x$*" == "x...." ]]; then cd ../../.. elif [[ "x$*" == "x....." ]]; then - cd ../../.. - elif [[ "x$*" == "x......" ]]; then cd ../../../.. + elif [[ "x$*" == "x......" ]]; then + cd ../../../../.. else builtin cd "$@" fi -- cgit v1.2.3-70-g09d2 From 43bd46b780cdf60b318f452e40b893ae18e77c41 Mon Sep 17 00:00:00 2001 From: Markus Scherer Date: Wed, 3 Oct 2012 17:18:14 +0200 Subject: fix title setting bug in xterm and urxvt Before this patch, commands containing %-signs set the title wrong (urxvt and xterm) [1] and produce strange output in urxvt [2]. test for bug 1: > sleep 10 && echo % sets title to "sleep 10 && echo %<<" > sleep 10 && echo %f doesn't change the title at all test for bug 2 (only urxvt): > echo %f 39m%f ^^^^^----- output --- lib/termsupport.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index e26fef6d3..4701e46c5 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -27,7 +27,7 @@ function omz_termsupport_preexec { emulate -L zsh setopt extended_glob local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd - title "$CMD" "%100>...>$2%<<" + title "$CMD" "%100>...>${2:gs/%/%%}%<<" } autoload -U add-zsh-hook -- cgit v1.2.3-70-g09d2 From daa6ecebc1034dab162c90b4fd7f4cb605d969d4 Mon Sep 17 00:00:00 2001 From: Felix Dreissig Date: Sat, 13 Oct 2012 22:53:34 +0200 Subject: Set the '-R' option for less not in $PAGER, but as $LESS. --- lib/misc.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/misc.zsh b/lib/misc.zsh index 0f7e7e925..a8678b8ec 100644 --- a/lib/misc.zsh +++ b/lib/misc.zsh @@ -9,5 +9,7 @@ bindkey "^[m" copy-prev-shell-word setopt long_list_jobs ## pager -export PAGER="less -R" +export PAGER="less" +export LESS="-R" + export LC_CTYPE=$LANG -- cgit v1.2.3-70-g09d2 From 5b2ca3875a15bbae4f064cb98935461df2e93e15 Mon Sep 17 00:00:00 2001 From: CHH Date: Wed, 14 Nov 2012 19:09:13 +0800 Subject: Improved statistics functions, effect: 1 1124 24.6006% c 2 985 21.5583% git 3 343 7.50711% rails 4 328 7.17881% cd 5 314 6.8724% rspec 6 257 5.62486% la 7 197 4.31167% rake 8 154 3.37054% s 9 109 2.38564% .. 10 95 2.07923% rvm 11 68 1.48829% guard 12 36 0.787919% bundle 13 29 0.634712% ssh 14 28 0.612826% pry 15 27 0.590939% open 16 26 0.569052% middleman 17 26 0.569052% gem 18 24 0.525279% rm 19 24 0.525279% heroku 20 23 0.503392% nvm --- lib/functions.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/functions.zsh b/lib/functions.zsh index d2dcadd0c..63ab755cf 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -1,5 +1,5 @@ function zsh_stats() { - history | awk '{print $2}' | sort | uniq -c | sort -rn | head + history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20 } function uninstall_oh_my_zsh() { -- cgit v1.2.3-70-g09d2 From 30687c414785fbc7d7d7d44ae60166075be75da7 Mon Sep 17 00:00:00 2001 From: Alexander Simonov Date: Sun, 22 May 2011 01:31:11 +0200 Subject: Fix RVM loading and RVM ruby version info --- lib/rvm.zsh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/rvm.zsh b/lib/rvm.zsh index cb870a9bb..a0a48960e 100644 --- a/lib/rvm.zsh +++ b/lib/rvm.zsh @@ -1,5 +1,11 @@ -# get the name of the branch we are on +# load RVM +[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm + +# get the name of the ruby version function rvm_prompt_info() { - ruby_version=$(~/.rvm/bin/rvm-prompt 2> /dev/null) || return - [[ ! -z $ruby_version ]] && echo "($ruby_version)" + [ -f $HOME/.rvm/bin/rvm-prompt ] || return + local rvm_prompt + rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null) + [[ "${rvm_prompt}x" == "x" ]] && return + echo "$ZSH_THEME_RVM_PROMPT_PREFIX$rvm_prompt$ZSH_THEME_RVM_PROMPT_SUFFIX" } -- cgit v1.2.3-70-g09d2 From 27841ca7c1bb6bd19e0eb66e1dcc8fa3a6a6ebba Mon Sep 17 00:00:00 2001 From: Alexander Simonov Date: Sun, 2 Dec 2012 20:30:25 +0200 Subject: Set default for rvm prompt prefix/suffix --- lib/rvm.zsh | 5 +---- themes/simonoff.zsh-theme | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/rvm.zsh b/lib/rvm.zsh index a0a48960e..e8744e61e 100644 --- a/lib/rvm.zsh +++ b/lib/rvm.zsh @@ -1,11 +1,8 @@ -# load RVM -[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm - # get the name of the ruby version function rvm_prompt_info() { [ -f $HOME/.rvm/bin/rvm-prompt ] || return local rvm_prompt rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null) [[ "${rvm_prompt}x" == "x" ]] && return - echo "$ZSH_THEME_RVM_PROMPT_PREFIX$rvm_prompt$ZSH_THEME_RVM_PROMPT_SUFFIX" + echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}" } diff --git a/themes/simonoff.zsh-theme b/themes/simonoff.zsh-theme index 01f381c48..fb4d32e24 100644 --- a/themes/simonoff.zsh-theme +++ b/themes/simonoff.zsh-theme @@ -95,7 +95,6 @@ setprompt () { # Modify RVM prompt ZSH_THEME_RVM_PROMPT_PREFIX=" [" ZSH_THEME_RVM_PROMPT_SUFFIX="]" - ZSH_THEME_RVM_PROMPT_OPTIONS=(v i) ### -- cgit v1.2.3-70-g09d2 From fe094712fb0c896eeec55b686807011226bc9208 Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Tue, 20 Dec 2011 18:15:19 -0800 Subject: resolving conflict in termsupport plugin --- lib/termsupport.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 4701e46c5..c056989eb 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -26,7 +26,7 @@ function omz_termsupport_precmd { function omz_termsupport_preexec { emulate -L zsh setopt extended_glob - local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd + local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd title "$CMD" "%100>...>${2:gs/%/%%}%<<" } -- cgit v1.2.3-70-g09d2 From b9a989fea5f0462b3ced71a33abd3cec3e7809cb Mon Sep 17 00:00:00 2001 From: MAD Date: Fri, 7 Dec 2012 10:07:45 +0100 Subject: Add Stash toogle to display if there's some stash or not in `git_prompt_status` --- lib/git.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/git.zsh b/lib/git.zsh index 95dd3dd43..b1dfce357 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -85,6 +85,9 @@ git_prompt_status() { elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" fi + if $(git rev-parse --verify refs/stash >/dev/null 2>&1); then + STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS" + fi if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" fi @@ -102,7 +105,7 @@ git_prompt_status() { #compare the provided version of git to the version installed and on path #prints 1 if input version <= installed version -#prints -1 otherwise +#prints -1 otherwise function git_compare_version() { local INPUT_GIT_VERSION=$1; local INSTALLED_GIT_VERSION -- cgit v1.2.3-70-g09d2 From c5ecb4e13691404a4555dbf6fa72fe411d463ad9 Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Mon, 31 Dec 2012 05:25:07 -0800 Subject: Fixes #1489 Revert "Fixed Mac OS X Terminal.app related issue with extra newlines being printed out sometimes" This reverts commit 8f89d4d5a5d584bae288d8111d83a6489a1369dc. --- lib/termsupport.zsh | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib') diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 7470110b6..c056989eb 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -8,8 +8,6 @@ function title { fi if [[ "$TERM" == screen* ]]; then print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars - elif [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then - print -Pn "\e]1;$1:q\a" #set icon (=tab) name (will override window name on broken terminal) elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then print -Pn "\e]2;$2:q\a" #set window name print -Pn "\e]1;$1:q\a" #set icon (=tab) name (will override window name on broken terminal) -- cgit v1.2.3-70-g09d2