]> git.madduck.net Git - etc/zsh.git/blobdiff - .zsh/zshrc/85_vcs_prompt

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Prefix bzr branch
[etc/zsh.git] / .zsh / zshrc / 85_vcs_prompt
index e96b7728f41eda77213ac5b7794cc2317f56621c..0c9db4610cd82230793834fa729d784f70a2690f 100644 (file)
@@ -31,6 +31,38 @@ __git_get_branch()
   echo "${ref#refs/heads/}"
 }
 
   echo "${ref#refs/heads/}"
 }
 
+__hg_get_reporoot()
+{
+  hg root
+}
+
+__hg_get_branch()
+{
+  echo "hg:$(hg branch)"
+}
+
+__bzr_get_reporoot()
+{
+  local reporoot
+  reporoot="$(bzr info | sed -rne 's, *branch root: ,,p')"
+  case "$reporoot" in
+    .) echo "$PWD";;
+    *) echo "$reporoot";;
+  esac
+}
+
+__bzr_get_branch()
+{
+  local branch revno
+  bzr version-info | while read i j; do
+      case "$i" in
+        revno:) revno="$j";;
+        branch-nick:) branch="$j";;
+      esac
+    done
+  echo "bzr:${branch}@$revno"
+}
+
 __vcs_get_repo_type()
 {
   # return the type of the closest repository in the path hierarchy
 __vcs_get_repo_type()
 {
   # return the type of the closest repository in the path hierarchy
@@ -115,6 +147,18 @@ __vcs_set_prompt_variables()
       branch="$(__git_get_branch)" ||
         { error "could not determine git branch"; return 1 }
       ;;
       branch="$(__git_get_branch)" ||
         { error "could not determine git branch"; return 1 }
       ;;
+    hg)
+      reporoot="$(__hg_get_reporoot)" ||
+        { error "could not determine hg repository root"; return 1 }
+      branch="$(__hg_get_branch)" ||
+        { error "could not determine hg branch"; return 1 }
+      ;;
+    bzr)
+      reporoot="$(__bzr_get_reporoot)" ||
+        { error "could not determine bzr repository root"; return 1 }
+      branch="$(__bzr_get_branch)" ||
+        { error "could not determine bzr branch"; return 1 }
+      ;;
     *)
       case "$repotype" in
         NONE) :;;
     *)
       case "$repotype" in
         NONE) :;;