You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With watch git status the color is not there; but, when printed onto the screen, it is.
watch --color git-substatus shows the output with color, but that's a separate parameter added to the watch command.
If I add watch git -c color.status=always status, I see the git status with the escape code.
So how does git know when to add the escape codes?
Answer: there's a way to check if a file is opened on terminal
man test
...
-t FD file descriptor FD is opened on a terminal
...
echo'''#!/bin/bashtext="Hello world"if [ -t 1 ]; then echo "***stdout is a terminal***" text="$(printf "%s" "\e[31m$text\e[0m")"fiecho -e "$text"'''> test.sh
chmod +x test.sh
./test.sh
# ***stdout is a terminal***# Hello world#
watch ./test.sh
# Every 2.0s: ./test.sh## Hello world#
TODO
Implement that color codes are added if the stdout is going to the terminal
new arg: --color always prints color
new arg: --no-color never prints color
Add tests with watch
Watch 1 time & parse the output.
watch args
git-substatus args
color codes printed
--color
--color
false
--color
--no-color
false
``
--color
true
``
--no-color
false
The text was updated successfully, but these errors were encountered:
When running
git-substatus
withwatch
, the output is not clean due to the escape codes:With
watch git status
the color is not there; but, when printed onto the screen, it is.watch --color git-substatus
shows the output with color, but that's a separate parameter added to thewatch
command.If I add
watch git -c color.status=always status
, I see the git status with the escape code.So how does git know when to add the escape codes?
Answer: there's a way to check if a file is opened on terminal
TODO
--color
always prints color--no-color
never prints colorwatch
Watch 1 time & parse the output.
--color
--color
false
--color
--no-color
false
--color
true
--no-color
false
The text was updated successfully, but these errors were encountered: