Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds notes, todo counts in RPROMPT

  • Loading branch information...
commit 07ab22388d2beb561244c235f51cebd5aa30fb14 1 parent b989de9
@pengwynn authored
Showing with 30 additions and 2 deletions.
  1. +30 −2 zsh/prompt.zsh
View
32 zsh/prompt.zsh
@@ -131,7 +131,7 @@ function git_time_since_commit() {
todo_count(){
if $(which todo &> /dev/null)
then
- num=$(echo $(todo ls +next | wc -l))
+ num=$(echo $(todo ls $1 | wc -l))
let todos=num-2
if [ $todos != 0 ]
then
@@ -144,13 +144,41 @@ todo_count(){
fi
}
+function todo_prompt() {
+ local COUNT=$(todo_count $1);
+ if [ $COUNT != 0 ]; then
+ echo "$1: $COUNT";
+ else
+ echo "";
+ fi
+}
+
+function notes_count() {
+ if [[ -z $1 ]]; then
+ local NOTES_PATTERN="TODO|FIXME|HACK";
+ else
+ local NOTES_PATTERN=$1;
+ fi
+ grep -ERni "\b($NOTES_PATTERN)\b" {app,config,lib,spec,test} 2>/dev/null | wc -l | sed 's/ //g'

You could even do what they did for the bundler plugin and have this run from the directory where .git exists making it effectively show the counts for the current "project".

https://github.com/robbyrussell/oh-my-zsh/blob/0da18650c6d8f63c230c36e92786855361f42ef3/plugins/bundler/bundler.plugin.zsh#L17-24

@pengwynn Owner

Oh nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+}
+
+function notes_prompt() {
+ local COUNT=$(notes_count $1);
+ if [ $COUNT != 0 ]; then
+ echo "$1: $COUNT";
+ else
+ echo "";
+ fi
+}
+
+
export PROMPT='%{$fg[blue]%}%c \
$(git_prompt_info)\
$(git_time_since_commit)%{$reset_color%} \
%{$fg[white]%}%(!.#.⚡)%{$reset_color%} '
set_prompt () {
- export RPROMPT="%{$fg_bold[blue]%}$(todo_count)%{$reset_color%}"
+ export RPROMPT="$(notes_prompt TODO) %{$fg_bold[yellow]%}$(notes_prompt HACK)%{$reset_color%} %{$fg_bold[red]%}$(notes_prompt FIXME)%{$reset_color%} %{$fg_bold[white]%}$(todo_prompt +next)%{$reset_color%}"
}
precmd() {
@jessedearing

You could even do what they did for the bundler plugin and have this run from the directory where .git exists making it effectively show the counts for the current "project".

https://github.com/robbyrussell/oh-my-zsh/blob/0da18650c6d8f63c230c36e92786855361f42ef3/plugins/bundler/bundler.plugin.zsh#L17-24

@pengwynn

Oh nice!

Please sign in to comment.
Something went wrong with that request. Please try again.