Skip to content

Instantly share code, notes, and snippets.

@humus
Created July 4, 2014 23:02
Show Gist options
  • Save humus/41d4801e05f396efd257 to your computer and use it in GitHub Desktop.
Save humus/41d4801e05f396efd257 to your computer and use it in GitHub Desktop.
#!/bin/bash
RESET="\033[0m"
TERMINAL_DEFAULT="\033[39m"
BLACK="\033[30m"
BLACK_DIM="\033[2;30m"
RED="\033[31m"
GREEN="\033[32m"
YELLOW="\033[33m"
BLUE="\033[34m"
MAGENTA="\033[35m"
CYAN="\033[36m"
LIGHT_GRAY="\033[37m"
DARK_GRAY="\033[90m"
LIGHT_RED="\033[91m"
LIGHT_GREEN="\033[92m"
LIGHT_YELLOW="\033[93m"
LIGHT_BLUE="\033[94m"
LIGHT_MAGENTA="\033[95m"
LIGHT_CYAN="\033[96m"
DIM="\033[37m"
WHITE="\033[97m"
REVSET="$YELLOW{rev}:{shortest(node)}"
PHASE="$BLACK{phase}"
WHEN="$GREEN{date|age}"
AUTHOR="$DIM{author|email}$RESET"
REFS="$RED{if(nonempty(bookmarks), '{bookmarks} ')}{if(nonempty(tags), '{tags} ')}$RESET"
DESC="{desc}"
LOG_TEMPLATE="$REVSET:$PHASE°$WHEN$WHITE°$AUTHOR°$REFS$DESC\n"
yellow(){
echo -e "$YELLOW"
}
hg_log() {
hg log -G --template="$LOG_TEMPLATE" $* |
sed "s/^\\([o@]\\)[[:space:]]*/\\1 /;/^.$/d"|
sed "s/draft\\b/d/;s/\\([[:digit:]]m[^@]\\+\\)@[^°]\\+/\1/" | sed 's/\(\w\+\) ago/\1/' |
sed 's/\(.\{4\}[^[:digit:]][[:digit:]]\)[[:space:]]\+\(hours\|days\|weeks\|months\|years\)/ \1 \2/' |
column -t -s '°' | cut -c1-"$((`tput cols`+37))"
}
hg_log $*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment