From 926d116259ee46b718d2a2fa068dcc6d1bbd426f Mon Sep 17 00:00:00 2001 From: Steve Losh Date: Mon, 18 Jan 2010 11:46:41 -0500 Subject: [PATCH 01/10] Add a new "prose" theme. --- themes/prose.zsh-theme | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 themes/prose.zsh-theme diff --git a/themes/prose.zsh-theme b/themes/prose.zsh-theme new file mode 100644 index 000000000..d83361e61 --- /dev/null +++ b/themes/prose.zsh-theme @@ -0,0 +1,32 @@ +function prompt_char { + git branch >/dev/null 2>/dev/null && echo '±' && return + hg root >/dev/null 2>/dev/null && echo '☿' && return + echo '○' +} + +function battery_charge { + echo `$BAT_CHARGE` 2>/dev/null +} + +function virtualenv_info { + [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') ' +} + +function hg_prompt_info { + hg prompt --angle-brackets "\ +< on %{$fg[magenta]%}%{$reset_color%}>\ +< at %{$fg[yellow]%}%{$reset_color%}>\ +%{$fg[green]%}%{$reset_color%}< +patches: >" 2>/dev/null +} + +PROMPT=' +%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}%~%{$reset_color%}$(hg_prompt_info)$(git_prompt_info) +$(virtualenv_info)$(prompt_char) ' + +RPROMPT='$(battery_charge)' + +ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!" +ZSH_THEME_GIT_PROMPT_CLEAN="" From 0f711cab40a8d838e7bffd3a114bd1c689e7b952 Mon Sep 17 00:00:00 2001 From: Steve Losh Date: Mon, 18 Jan 2010 11:47:06 -0500 Subject: [PATCH 02/10] Switch around the .gitignore a bit to account for symlinking. --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f84db6dc2..18a09e24d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ locals.zsh log/.zsh_history projects.zsh +custom custom/*.zsh -!custom/example.zsh \ No newline at end of file +!custom/example.zsh From d136031d3552c4c136a210809c2df6981cc80d39 Mon Sep 17 00:00:00 2001 From: Steve Losh Date: Wed, 20 Jan 2010 00:40:13 -0500 Subject: [PATCH 03/10] Fix the collapsed-pwd. --- themes/prose.zsh-theme | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/themes/prose.zsh-theme b/themes/prose.zsh-theme index d83361e61..319e620f5 100644 --- a/themes/prose.zsh-theme +++ b/themes/prose.zsh-theme @@ -1,3 +1,7 @@ +function collapse_pwd { + echo $(pwd | sed -e "s,^$HOME,~,") +} + function prompt_char { git branch >/dev/null 2>/dev/null && echo '±' && return hg root >/dev/null 2>/dev/null && echo '☿' && return @@ -21,7 +25,7 @@ patches: Date: Wed, 20 Jan 2010 00:41:41 -0500 Subject: [PATCH 04/10] Add annoying OS X files to the ignore. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 18a09e24d..e173dab09 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ projects.zsh custom custom/*.zsh !custom/example.zsh + +.DS_Store From 3d22ee248c6bce357c018a93d31f8d292d2cb4cd Mon Sep 17 00:00:00 2001 From: Steve Losh Date: Wed, 20 Jan 2010 12:12:48 -0500 Subject: [PATCH 05/10] Improve the git prompt. --- lib/git.zsh | 16 ++++++++++++---- themes/prose.zsh-theme | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index 629a08b0e..a34140d89 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -5,10 +5,18 @@ function git_prompt_info() { } parse_git_dirty () { - if [[ $((git status 2> /dev/null) | tail -n1) != "nothing to commit (working directory clean)" ]]; then - echo "$ZSH_THEME_GIT_PROMPT_DIRTY" - else - echo "$ZSH_THEME_GIT_PROMPT_CLEAN" + gitstat=$(git status 2>/dev/null | grep '\(# Untracked\|# Changes\|# Changed but not updated:\)') + + if [[ $(echo ${gitstat} | grep -c "^# Changes to be committed:$") > 0 ]]; then + echo -n "$ZSH_THEME_GIT_PROMPT_DIRTY" + fi + + if [[ $(echo ${gitstat} | grep -c "^\(# Untracked files:\|# Changed but not updated:\)$") > 0 ]]; then + echo -n "$ZSH_THEME_GIT_PROMPT_UNTRACKED" + fi + + if [[ $(echo ${gitstat} | wc -l | tr -d ' ') == 0 ]]; then + echo -n "$ZSH_THEME_GIT_PROMPT_CLEAN" fi } diff --git a/themes/prose.zsh-theme b/themes/prose.zsh-theme index 319e620f5..9071ee07f 100644 --- a/themes/prose.zsh-theme +++ b/themes/prose.zsh-theme @@ -33,4 +33,5 @@ RPROMPT='$(battery_charge)' ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?" ZSH_THEME_GIT_PROMPT_CLEAN="" From 6ec9f8c1688c3e99e301632aa818763c28fad896 Mon Sep 17 00:00:00 2001 From: Steve Losh Date: Mon, 25 Jan 2010 09:06:45 -0500 Subject: [PATCH 06/10] Clear new tabs. --- lib/functions.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/functions.zsh b/lib/functions.zsh index 74b93f00e..aa974e5c2 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -44,7 +44,7 @@ function tab() { end tell application "Terminal" activate - do script with command "cd \"$PWD\"; $*" in window 1 + do script with command "cd \"$PWD\"; clear; $*" in window 1 end tell EOF } From 26866cf4be95b1e1bfc427a8228b8e6e3d5c62b9 Mon Sep 17 00:00:00 2001 From: Steve Losh Date: Mon, 1 Feb 2010 18:43:54 -0500 Subject: [PATCH 07/10] themes/prose: Replace collapse_pwd with a built-in version. --- themes/prose.zsh-theme | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/themes/prose.zsh-theme b/themes/prose.zsh-theme index 9071ee07f..cab930f87 100644 --- a/themes/prose.zsh-theme +++ b/themes/prose.zsh-theme @@ -1,7 +1,3 @@ -function collapse_pwd { - echo $(pwd | sed -e "s,^$HOME,~,") -} - function prompt_char { git branch >/dev/null 2>/dev/null && echo '±' && return hg root >/dev/null 2>/dev/null && echo '☿' && return @@ -25,7 +21,7 @@ patches: Date: Tue, 2 Feb 2010 09:11:41 -0500 Subject: [PATCH 08/10] Add bare dot aliases for backing out of directories. --- lib/directories.zsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/directories.zsh b/lib/directories.zsh index 56d7a2316..146a5b069 100644 --- a/lib/directories.zsh +++ b/lib/directories.zsh @@ -4,6 +4,9 @@ setopt auto_pushd setopt pushd_ignore_dups alias ..='cd ..' +alias ...='cd ../..' +alias ....='cd ../../..' +alias .....='cd ../../../..' alias cd..='cd ..' alias cd...='cd ../..' alias cd....='cd ../../..' From 863b28411fa9b96ad4ef7f296ee8c1548af51d21 Mon Sep 17 00:00:00 2001 From: Steve Losh Date: Tue, 2 Feb 2010 09:21:54 -0500 Subject: [PATCH 09/10] Load zmv to help with complex renames. --- lib/misc.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/misc.zsh b/lib/misc.zsh index 4c1743657..bf68182e1 100644 --- a/lib/misc.zsh +++ b/lib/misc.zsh @@ -3,6 +3,7 @@ autoload -U url-quote-magic zle -N self-insert url-quote-magic ## file rename magick +autoload -U zmv bindkey "^[m" copy-prev-shell-word ## jobs From 7bde96c7b207a9989fac19882c4553f7b0d07670 Mon Sep 17 00:00:00 2001 From: Steve Losh Date: Tue, 2 Feb 2010 09:26:02 -0500 Subject: [PATCH 10/10] Add a file for Python-related things. --- lib/python.zsh | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 lib/python.zsh diff --git a/lib/python.zsh b/lib/python.zsh new file mode 100644 index 000000000..79c8e151e --- /dev/null +++ b/lib/python.zsh @@ -0,0 +1,3 @@ +function wo() { + [ -f './.venv' ] && workon `cat ./.venv` +}