diff --git a/lib/appearance.zsh b/lib/appearance.zsh index ffee52b5e..1e6c8d1f1 100644 --- a/lib/appearance.zsh +++ b/lib/appearance.zsh @@ -34,5 +34,22 @@ ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is c # Setup the prompt with pretty colors setopt prompt_subst + +#load scm prompt info +ZSH_THEME_SCM_DISPLAY_NAME=0 +for scm in $scms; do + source $ZSH/scm/$scm.scm.zsh +done + + + +function get_scm_prompt () { + for scm in $scms; do + if [ $("scm_in_"$scm"_repo") ]; then + echo `"scm_"$scm"_prompt_info"` + fi + done +} + # Load the theme source "$ZSH/themes/$ZSH_THEME.zsh-theme" \ No newline at end of file diff --git a/scm/git.scm.zsh b/scm/git.scm.zsh new file mode 100644 index 000000000..095f36012 --- /dev/null +++ b/scm/git.scm.zsh @@ -0,0 +1,22 @@ +function scm_in_git_repo () { + if [[ -d .git ]]; then + echo 1 + fi +} + +function scm_git_prompt_info() { + ref=$(git symbolic-ref HEAD 2> /dev/null) || return + out="$ZSH_THEME_SCM_PROMPT_PREFIX${ref#refs/heads/}$(scm_parse_git_dirty)$ZSH_THEME_SCM_PROMPT_SUFFIX" + if [[ ZSH_THEME_SCM_DISPLAY_NAME -eq 1 ]]; then + out="git$out" + fi + echo $out +} + +scm_parse_git_dirty () { + if [[ -n $(git status -s 2> /dev/null) ]]; then + echo "$ZSH_THEME_SCM_PROMPT_DIRTY" + else + echo "$ZSH_THEME_SCM_PROMPT_CLEAN" + fi +} \ No newline at end of file diff --git a/scm/svn.scm.zsh b/scm/svn.scm.zsh new file mode 100644 index 000000000..1d5410724 --- /dev/null +++ b/scm/svn.scm.zsh @@ -0,0 +1,42 @@ +function scm_in_svn_repo() { + if [[ -d .svn ]]; then + echo 1 + fi +} + +function scm_svn_prompt_info { + if [ -d .svn ]; then + out="$ZSH_THEME_SCM_PROMPT_PREFIX$(svn_get_repo_name)$(parse_svn_dirty)$ZSH_THEME_SCM_PROMPT_SUFFIX" + if [[ ZSH_THEME_SCM_DISPLAY_NAME -eq 1 ]]; then + out="svn$out" + fi + echo $out + fi +} + +function svn_get_repo_name { + if [ in_svn_repo ]; then + svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT + + svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p" | sed "s/\/.*$//" + fi +} + +function svn_get_rev_nr { + if [ in_svn_repo ]; then + svn info 2> /dev/null | sed -n s/Revision:\ //p + fi +} + +function parse_svn_dirty { + if [ in_svn_repo ]; then + s=$(svn status 2>/dev/null) + if [ $s ]; then + echo $ZSH_THEME_SCM_PROMPT_DIRTY + else + echo $ZSH_THEME_SCM_PROMPT_CLEAN + fi + fi +} + +ZSH_THEME_SVN_NAME="svn" \ No newline at end of file diff --git a/themes/awesomepanda.zsh-theme b/themes/awesomepanda.zsh-theme new file mode 100644 index 000000000..e0bb3e73f --- /dev/null +++ b/themes/awesomepanda.zsh-theme @@ -0,0 +1,11 @@ +# the svn plugin has to be activated for this to work. + +PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(get_scm_prompt)%{$reset_color%}' + +ZSH_THEME_SCM_PROMPT_PREFIX=":(%{$fg[red]%}" +ZSH_THEME_SCM_PROMPT_SUFFIX=" %{$reset_color%}" +ZSH_THEME_SCM_PROMPT_DIRTY="%{$fg_bold[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}" +ZSH_THEME_SCM_PROMPT_CLEAN="%{$fg_bold[blue]%})%{$reset_color%}" + +ZSH_THEME_SCM_DISPLAY_NAME=1 +