forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable color output whenever stdout is TTY (JuliaLang#34347)
Fixes JuliaLang#34317
- Loading branch information
Showing
9 changed files
with
43 additions
and
31 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
if Sys.iswindows() | ||
ttyhascolor(term_type = nothing) = true | ||
else | ||
function ttyhascolor(term_type = get(ENV, "TERM", "")) | ||
startswith(term_type, "xterm") && return true | ||
try | ||
@static if Sys.KERNEL === :FreeBSD | ||
return success(`tput AF 0`) | ||
else | ||
return success(`tput setaf 0`) | ||
end | ||
catch e | ||
return false | ||
end | ||
end | ||
end | ||
function get_have_color() | ||
global have_color | ||
have_color === nothing && (have_color = ttyhascolor()) | ||
return have_color::Bool | ||
end | ||
in(key_value::Pair{Symbol,Bool}, ::TTY) = key_value.first === :color && key_value.second === get_have_color() | ||
haskey(::TTY, key::Symbol) = key === :color | ||
getindex(::TTY, key::Symbol) = key === :color ? get_have_color() : throw(KeyError(key)) | ||
get(::TTY, key::Symbol, default) = key === :color ? get_have_color() : default |
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
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
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