Skip to content
This repository

Mercurial repository info in agnoster theme #1558

Merged
merged 4 commits into from about 1 year ago

5 participants

Yohann Bianchi Zachary Fand Tharshan Muthulingam Andy Beaumont Robby Russell
Yohann Bianchi

I modded agnoster theme to add the same functionality it has for git. It displays the status of the mercurial repository, if any in cwd.
Capture d e cran 2013-01-20 a 13 17 11

Andy Beaumont

Thank you. I've previously tried and failed to get this working.

You're welcome. Glad it helped someone.
If you need to make it work without the prompt extension, see my next commit.

Zachary Fand
zfand commented

You're the best!

Tharshan Muthulingam

Thanks you, this is really nice. Just wish it was a bit faster/

Yohann Bianchi
Tharshan Muthulingam

Ah actually i do have that extension - is it enabled by default? or do i have to edit it ?

Yohann Bianchi
Tharshan Muthulingam

Ah not that is not what I meant. I know the extension is enabled, and i can see it listed with that command. However, I was asking if the additions to your script use that extension? or will i need to edit it?

Yohann Bianchi
Yohann Bianchi IMPROVED: untracked file status has priority over modified (ie: if yo…
…u have both modified and untracked files, your prompt will be red indicating the presence of untracked files)
5128669
Robby Russell robbyrussell merged commit 4e101be into from
Robby Russell robbyrussell closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 4 unique commits by 1 author.

Jan 19, 2013
Yohann Bianchi ADDED: Mercurial repository info 8e9cf45
Jan 20, 2013
Yohann Bianchi ADDED: Mercurial prompt info support even if hg prompt extension is u…
…navailable
28b7374
Feb 18, 2013
Yohann Bianchi Merge branch 'master' of https://github.com/robbyrussell/oh-my-zsh 5eb3ec6
Mar 26, 2013
Yohann Bianchi IMPROVED: untracked file status has priority over modified (ie: if yo…
…u have both modified and untracked files, your prompt will be red indicating the presence of untracked files)
5128669
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 36 additions and 0 deletions. Show diff stats Hide diff stats

  1. 36  themes/agnoster.zsh-theme
36  themes/agnoster.zsh-theme
@@ -83,6 +83,41 @@ prompt_git() {
83 83
   fi
84 84
 }
85 85
 
  86
+prompt_hg() {
  87
+	local rev status
  88
+	if $(hg id >/dev/null 2>&1); then
  89
+		if $(hg prompt >/dev/null 2>&1); then
  90
+			if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
  91
+				# if files are not added
  92
+				prompt_segment red white
  93
+				st='±'
  94
+			elif [[ -n $(hg prompt "{status|modified}") ]]; then
  95
+				# if any modification
  96
+				prompt_segment yellow black
  97
+				st='±'
  98
+			else
  99
+				# if working copy is clean
  100
+				prompt_segment green black
  101
+			fi
  102
+			echo -n $(hg prompt "⭠ {rev}@{branch}") $st
  103
+		else
  104
+			st=""
  105
+			rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
  106
+			branch=$(hg id -b 2>/dev/null)
  107
+			if `hg st | grep -Eq "^\?"`; then
  108
+				prompt_segment red black
  109
+				st='±'
  110
+			elif `hg st | grep -Eq "^(M|A)"`; then
  111
+				prompt_segment yellow black
  112
+				st='±'
  113
+			else
  114
+				prompt_segment green black
  115
+			fi
  116
+			echo -n "⭠ $rev@$branch" $st
  117
+		fi
  118
+	fi
  119
+}
  120
+
86 121
 # Dir: current working directory
87 122
 prompt_dir() {
88 123
   prompt_segment blue black '%~'
@@ -109,6 +144,7 @@ build_prompt() {
109 144
   prompt_context
110 145
   prompt_dir
111 146
   prompt_git
  147
+  prompt_hg
112 148
   prompt_end
113 149
 }
114 150
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.