From fd4454502e7718cb224f636860ddd5133f6e388f Mon Sep 17 00:00:00 2001 From: Marin Marusic Date: Sun, 29 Sep 2013 13:19:22 +0200 Subject: [PATCH 1/4] =?UTF-8?q?Changed=20git.plugin.zsh=20>=20added=20an?= =?UTF-8?q?=20in=5Fgit=20function=20Added=20a=20netpunk.zsh-theme=20?= =?UTF-8?q?=E2=80=A6=20displays=20battery=20charge=20remaining=20using=20b?= =?UTF-8?q?atcharge.py,=20date,=20ruby=20version=20via=20rbenv,=20points?= =?UTF-8?q?=20out=20werther=20you're=20in=20a=20GIT=20or=20HG=20repository?= =?UTF-8?q?,=20has=20improved=20HG=20functions,=20but=20requires=20hg=20pl?= =?UTF-8?q?ugins=20prompt,=20tasks=20and=20mq.=20I=20built=20it,=20and=20n?= =?UTF-8?q?ow=20it's=20up=20for=20grabs=20:)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/git/git.plugin.zsh | 7 +++++ themes/netpunk.zsh-theme | 52 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 themes/netpunk.zsh-theme diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index d8ea3ae0c..50f443e9b 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -97,6 +97,13 @@ compdef git-svn-dcommit-push=git alias gsr='git svn rebase' alias gsd='git svn dcommit' + +function in_git { + if $(git status > /dev/null 2>&1); then + echo 1 + fi +} + # # Will return the current branch name # Usage example: git pull origin $(current_branch) diff --git a/themes/netpunk.zsh-theme b/themes/netpunk.zsh-theme new file mode 100644 index 000000000..fb985a83a --- /dev/null +++ b/themes/netpunk.zsh-theme @@ -0,0 +1,52 @@ +function prompt_char { + git branch >/dev/null 2>/dev/null && echo 'GIT ☢ ↪' && return + hg root >/dev/null 2>/dev/null && echo 'HG ☢ ↪' && return + echo ' ☣ ↪' +} +function battery_charge() { + if [ -e /usr/local/bin/batcharge.py ] + then + echo `python /usr/local/bin/batcharge.py` + else + echo ''; + fi +} + +function hg_prompt_info { + if [ $(in_hg) ]; then + hg prompt "{rev}:{node|short} on {root|basename}:{branch} {task} {status|modified} {patch|count|unapplied} {incoming changes{incoming|count}} {update}" 2>/dev/null + fi +} + +function get_pwd() { + echo "${PWD/$HOME/~}" +} + +function virtualenv_info { + [ $VIRTUAL_ENV ] && echo '('on `basename $VIRTUAL_ENV`') ' +} +function spacing { + local spacing="" + for i in {1..$termwidth}; do + spacing="${spacing} " + done + echo $spacing +} +function collapse_pwd { + echo $(pwd | sed -e "s,^$HOME,~,") +} + +if which rbenv &> /dev/null; then + PROMPT='%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%} %~ %{$reset_color%}$(hg_prompt_info)$(git_prompt_info)%{$reset_color%} + $(prompt_char) ' + RPROMPT='using %{$fg[red]%}$(rbenv version | sed -e "s/ (set.*$//")%{$reset_color%}$(virtualenv_info) %{$fg[magenta]%}$(date "+%Y-%m-%d")%{$reset_color%} BAT: $(battery_charge)' + +fi + + + +ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%} " +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[white]%}%{$bg[red]%} ✖ " +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[white]%}%{$bg[magenta]%} ◘ " +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%} ✔ " From 8e53e2e5a1e2fb538a9e578b13f3389543b01e6b Mon Sep 17 00:00:00 2001 From: Marin Marusic Date: Sun, 29 Sep 2013 13:36:44 +0200 Subject: [PATCH 2/4] =?UTF-8?q?done=20a=20bit=20of=20refactoring,=20moved?= =?UTF-8?q?=20out=20some=20stuff=20I=20don't=20need=20like=20virtual=5Fenv?= =?UTF-8?q?=20checks=20and=20so=20on.=20Also=20put=20up=20a=20header=20and?= =?UTF-8?q?=20license=20(MIT)=20=E2=80=A6=20'tis=20changeable=20to=20=20wh?= =?UTF-8?q?atever=20as=20long=20as=20it's=20free=20to=20use/modify/redistr?= =?UTF-8?q?ibute.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/netpunk.zsh-theme | 41 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/themes/netpunk.zsh-theme b/themes/netpunk.zsh-theme index fb985a83a..3b42d8714 100644 --- a/themes/netpunk.zsh-theme +++ b/themes/netpunk.zsh-theme @@ -1,9 +1,24 @@ +## +# Developed by NETPUNK#, software services +# http://www.netpunk.net (not up ATM) +# +# License: MIT +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +## + function prompt_char { git branch >/dev/null 2>/dev/null && echo 'GIT ☢ ↪' && return hg root >/dev/null 2>/dev/null && echo 'HG ☢ ↪' && return - echo ' ☣ ↪' + echo ' ☢ ↪' } -function battery_charge() { +function battery_charge { if [ -e /usr/local/bin/batcharge.py ] then echo `python /usr/local/bin/batcharge.py` @@ -18,33 +33,13 @@ function hg_prompt_info { fi } -function get_pwd() { - echo "${PWD/$HOME/~}" -} - -function virtualenv_info { - [ $VIRTUAL_ENV ] && echo '('on `basename $VIRTUAL_ENV`') ' -} -function spacing { - local spacing="" - for i in {1..$termwidth}; do - spacing="${spacing} " - done - echo $spacing -} -function collapse_pwd { - echo $(pwd | sed -e "s,^$HOME,~,") -} - if which rbenv &> /dev/null; then PROMPT='%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%} %~ %{$reset_color%}$(hg_prompt_info)$(git_prompt_info)%{$reset_color%} $(prompt_char) ' - RPROMPT='using %{$fg[red]%}$(rbenv version | sed -e "s/ (set.*$//")%{$reset_color%}$(virtualenv_info) %{$fg[magenta]%}$(date "+%Y-%m-%d")%{$reset_color%} BAT: $(battery_charge)' + RPROMPT='using %{$fg[red]%}$(rbenv version | sed -e "s/ (set.*$//")%{$reset_color%} %{$fg[magenta]%}$(date "+%Y-%m-%d")%{$reset_color%} BAT: $(battery_charge)' fi - - ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%} " ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[white]%}%{$bg[red]%} ✖ " From a28e653d570589e3b7c7176e59be4d951690b63f Mon Sep 17 00:00:00 2001 From: Marin Marusic Date: Sun, 29 Sep 2013 14:02:36 +0200 Subject: [PATCH 3/4] - added rvm support - hg prompt counts only unapplied patches and incoming does only count, not display the incoming changes --- themes/netpunk.zsh-theme | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/themes/netpunk.zsh-theme b/themes/netpunk.zsh-theme index 3b42d8714..cd740abe2 100644 --- a/themes/netpunk.zsh-theme +++ b/themes/netpunk.zsh-theme @@ -29,14 +29,17 @@ function battery_charge { function hg_prompt_info { if [ $(in_hg) ]; then - hg prompt "{rev}:{node|short} on {root|basename}:{branch} {task} {status|modified} {patch|count|unapplied} {incoming changes{incoming|count}} {update}" 2>/dev/null + hg prompt "{rev}:{node|short} on {root|basename}/{branch} {task} {status} {update} {patch|count|unapplied} {incoming changes{incoming}} " 2>/dev/null fi } - -if which rbenv &> /dev/null; then +if which rvm-prompt &> /dev/null; then PROMPT='%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%} %~ %{$reset_color%}$(hg_prompt_info)$(git_prompt_info)%{$reset_color%} $(prompt_char) ' - RPROMPT='using %{$fg[red]%}$(rbenv version | sed -e "s/ (set.*$//")%{$reset_color%} %{$fg[magenta]%}$(date "+%Y-%m-%d")%{$reset_color%} BAT: $(battery_charge)' + RPROMPT='%{$fg[red]%}RB $(~/.rvm/bin/rvm-prompt)%{$reset_color%} %{$fg[magenta]%}$(date "+%Y-%m-%d")%{$reset_color%} %{$fg[green]%} BAT: %{$reset_color%} $(battery_charge)' +elif which rbenv &> /dev/null; then + PROMPT='%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%} %~ %{$reset_color%}$(hg_prompt_info)$(git_prompt_info)%{$reset_color%} + $(prompt_char) ' + RPROMPT='%{$fg[red]%}RB $(rbenv version | sed -e "s/ (set.*$//")%{$reset_color%} %{$fg[magenta]%}$(date "+%Y-%m-%d")%{$reset_color%} %{$fg[green]%} BAT: %{$reset_color%} $(battery_charge)' fi From 473dc4eeb017f7ce6c7057da588bf39337beb4be Mon Sep 17 00:00:00 2001 From: Marin Marusic Date: Sun, 29 Sep 2013 14:04:34 +0200 Subject: [PATCH 4/4] - forgot to save the incoming|count part --- themes/netpunk.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/netpunk.zsh-theme b/themes/netpunk.zsh-theme index cd740abe2..249edd9ec 100644 --- a/themes/netpunk.zsh-theme +++ b/themes/netpunk.zsh-theme @@ -29,7 +29,7 @@ function battery_charge { function hg_prompt_info { if [ $(in_hg) ]; then - hg prompt "{rev}:{node|short} on {root|basename}/{branch} {task} {status} {update} {patch|count|unapplied} {incoming changes{incoming}} " 2>/dev/null + hg prompt "{rev}:{node|short} on {root|basename}/{branch} {task} {status} {update} {patch|count|unapplied} {incoming changes{incoming|count}} " 2>/dev/null fi } if which rvm-prompt &> /dev/null; then