title: Pretend to be a tty in bash for any command
body: <p>Whenever I use <code>grep</code>, and I pipe it to an other program, the <code>--color</code> option is not respected. I know I could use <code>--color=always</code>, but It also comes up with some other commands that I would like to get the exact output of that command as the output I would get if I was in a tty.</p>
  
  <p>So my question is, is it possible to trick a command into thinking that the command is run inside a tty ?</p>
  
  <p>For example, running</p>
  
  <pre><code>grep --color word file # Outputs some colors
  grep --color word file | cat # Doesn't output any colors
  </code></pre>
  
  <p>I'd like to be able to write something like :</p>
  
  <pre><code>IS_TTY=TRUE grep --color word file | cat  # Outputs some colors
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/10527207/how-to-pretend-to-be-a-tty-when-trying-to-freebsd-update-from-a-shell-script">This question</a> seems to have a tool that might do what I want :<a href="http://empty.sourceforge.net/" rel="noreferrer">empty - run processes and applications under pseudo-terminal (PTY)</a>, but from what I could read in the docs, I'm not sure it can help for my problem</p>