Last active
June 5, 2020 15:20
-
-
Save nigjo/51f01247c4f777cbe8f58a9faac1daa5 to your computer and use it in GitHub Desktop.
Set color Env-Vars for Windows Batch scripts. DO NOT COPY PASTE THIS GIST. You should download the file to preserve the ESC characters.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
REM | |
REM Licensed to the Apache Software Foundation (ASF) under one | |
REM or more contributor license agreements. See the NOTICE file | |
REM distributed with this work for additional information | |
REM regarding copyright ownership. The ASF licenses this file | |
REM to you under the Apache License, Version 2.0 (the | |
REM "License"); you may not use this file except in compliance | |
REM with the License. You may obtain a copy of the License at | |
REM | |
REM http://www.apache.org/licenses/LICENSE-2.0 | |
REM | |
REM Unless required by applicable law or agreed to in writing, | |
REM software distributed under the License is distributed on an | |
REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
REM KIND, either express or implied. See the License for the | |
REM specific language governing permissions and limitations | |
REM under the License. | |
REM | |
REM (c) by Jens Hofschroeer - nigjo@github.com | |
REM https://gist.github.com/nigjo/51f01247c4f777cbe8f58a9faac1daa5 | |
REM | |
REM copy this to your original script and call | |
REM if exist "%~dp0clicolor.cmd" call "%~dp0clicolor.cmd" | |
REM | |
rem see https://bixense.com/clicolors/ | |
if defined CLICOLOR_FORCE if not "%CLICOLOR_FORCE%" == "0" goto :setcolors | |
if not defined CLICOLOR goto :eof | |
if "%CLICOLOR%" == "0" goto :eof | |
rem see Update on https://stackoverflow.com/a/52139735 | |
2>nul (5>&4 break) && ( | |
goto :eof | |
) | |
:setcolors | |
if defined CLICOL_NONE goto :eof | |
rem see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors | |
set CLICOL_NONE=[0m | |
set CLICOL_BLACK=[0;30m | |
set CLICOL_RED=[0;31m | |
set CLICOL_GREEN=[0;32m | |
set CLICOL_YELLOW=[0;33m | |
set CLICOL_BLUE=[0;34m | |
set CLICOL_PURPLE=[0;35m | |
set CLICOL_CYAN=[0;36m | |
set CLICOL_LGRAY=[0;37m | |
set CLICOL_GRAY=[1;30m | |
set CLICOL_LRED=[1;31m | |
set CLICOL_LGREEN=[1;32m | |
set CLICOL_YELLOW=[1;33m | |
set CLICOL_LBLUE=[1;34m | |
set CLICOL_LPURPLE=[1;35m | |
set CLICOL_LCYAN=[1;36m | |
set CLICOL_WHITE=[1;37m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment