I'm trying to run some commands remotely and recieve the output back with color. What am I missing?
Here's what I've got so far:
example.sh
. /etc/profile
[[ -f ~/.profile ]] && . ~/.profile;
[[ -f ~/.bashrc ]] && . ~/.bashrc;
echo "hello remote"
cd /vagrant/repositories/repo
pwd
phpunit --color
I'm piping the script into ssh as follows:
cat example.sh | ssh vagrant@localhost /bin/bash -s
Best Answer
Yes, it is possible using
-tt
switches, which will force TTY allocation and it will trick the remote program to write also the colors. Minimal test I can run on my system:Without colors:
With colors: