StevenBlack / hosts

🔒 Consolidating and extending hosts files from several well-curated sources. Optionally pick extensions for porn, social media, and other categories.
MIT License
26.9k stars 2.23k forks source link

Color text not working in cygwin or windows cmd #151

Closed bandophahita closed 7 years ago

bandophahita commented 8 years ago

The use of the color codes does not appear to work in windows commandline or cygwin (using ConsoleZ). I'm not entirely familiar, but I seem to recall reading once that windows terminal didn't support color injection in this way. If that's true, perhaps support could be added to disable the colorize() function?

example output:

$ updateHostsFile.py -b -r
←[94mDo you want to update all data sources?←[0m [Y/n] y
Updating source porn from https://raw.githubusercontent.com/Sinfonietta/hostfiles/master/pornography-hosts
Updating source gambling from https://raw.githubusercontent.com/Sinfonietta/hostfiles/master/gambling-hosts

Updating source tyzbit from https://raw.githubusercontent.com/tyzbit/hosts/master/data/tyzbit/hosts

Updating source StevenBlack from https://raw.githubusercontent.com/StevenBlack/hosts/master/data/StevenBlack/hosts

Updating source social from https://raw.githubusercontent.com/Sinfonietta/hostfiles/master/social-hosts

Updating source malwaredomainlist.com from http://www.malwaredomainlist.com/hostslist/hosts.txt

Updating source adaway.org from https://adaway.org/hosts.txt

Problem getting file:  https://adaway.org/hosts.txt

Skipping.
Updating source mvps.org from http://winhelp2002.mvps.org/hosts.txt

Updating source someonewhocares.org from http://someonewhocares.org/hosts/zero/hosts

Updating source yoyo.org from https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&mimetype=plaintext&useip=0.0.0.0

Updating source SpotifyAds from https://gist.githubusercontent.com/FadeMind/9305a12b227b0f5a61d41596c2bd6ef6/raw/8960222e70445f05827d02e25ec46dd494aa5ed6/spotify.ads.hosts
←[94mDo you want to exclude any domains?
For example, hulu.com video streaming must be able to access its tracking and ad servers in order to play video.←[0m [Y/n] y
←[94mDo you want to exclude the domain hulu.com ?←[0m [Y/n] y
←[94mDo you want to exclude any other domains?←[0m [Y/n] n
←[92mSuccess! The hosts file has been saved in folder
It contains 26,402 unique entries.←[0m
Automatically moving the hosts file in place is not yet supported.
Please move the generated file to %SystemRoot%\system32\drivers\etc\hosts
←[94mAttempt to flush the DNS cache?←[0m [Y/n] y
Flushing the DNS cache to utilize new hosts file...
Flushing the DNS cache requires administrative privileges. You might need to enter your password.
←[91mUnable to determine DNS management tool.←[0m
StevenBlack commented 8 years ago

Thanks for the observation @bandophahita.

The Windows console hasn't changed appreciably since the mid-1990's. So windows command line users have 99 other problems, so I'm inclined to just shrug.

That said, if you submit a Pull Request addressing this, I'd be happy to consider it.

gfyoung commented 7 years ago

@bandophahita : I've got a PR up that checks for terminal color support. It seems to work on Ubuntu (displays color) and Windows (no color support --> no weird characters). Can you check if it works for you?