therubymug / hitch

Git author attribution helper for pair programmers.
http://github.com/therubymug/hitch
MIT License
250 stars 32 forks source link

STDOUT.tty? breaks pipes #8

Open jimmycuadra opened 12 years ago

jimmycuadra commented 12 years ago

While writing a function to add Hitch info to my bash prompt, I was piping the output of hitch to cut, and wasn't getting any output. At first I thought I was doing something wrong in bash, but ultimately I discovered that Hitch.print_info is explicitly checking if STDOUT is a terminal and not outputting anything in that case. This prevents UNIX pipes from passing along the output of the command. Is there a reason this check is being made? Can it just be removed?

therubymug commented 12 years ago

At one point in time we had a hitch --info or --short that was used for this specific reason. It must have been lost in the major refactor I did a while back. I'll look into adding that back in for this.

dbi commented 11 years ago

I use this bash function in my prompt

function hitch_pair {
  source ~/.hitch_export_authors
  if [ `git symbolic-ref HEAD 2> /dev/null` ] && [ -n "${GIT_AUTHOR_EMAIL:+1}" ]; then
    echo $GIT_AUTHOR_EMAIL|awk -F "[+@]" '{ print " "$2"+"$3 }'
  fi
}