From 5a54ac0b2b915889950c83e04bf1beb08631891e Mon Sep 17 00:00:00 2001 From: Bodigrim Date: Sat, 4 Feb 2023 00:18:44 +0000 Subject: Fix colors in emacs terminal --- utils/ghc-pkg/Main.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'utils') diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs index 5fb6a85bce..8746b0296e 100644 --- a/utils/ghc-pkg/Main.hs +++ b/utils/ghc-pkg/Main.hs @@ -86,6 +86,7 @@ import qualified Data.ByteString as BS #if defined(mingw32_HOST_OS) import GHC.ConsoleHandler #else +import System.Environment (lookupEnv) import System.Posix hiding (fdToHandle) #endif @@ -1591,8 +1592,9 @@ listPackages verbosity my_flags mPackageName mModuleName = do pkg = display (mungedId p) is_tty <- hIsTerminalDevice stdout - -- Coloured text is a part of ANSI standard, no reason to query terminfo - mapM_ (if is_tty then show_colour else show_normal) stack + -- Equivalent of https://hackage.haskell.org/package/ansi-terminal/docs/System-Console-ANSI.html#v:hSupportsANSI + term <- lookupEnv "TERM" + mapM_ (if is_tty && term /= Just "dumb" then show_colour else show_normal) stack #endif simplePackageList :: [Flag] -> [InstalledPackageInfo] -> IO () -- cgit v1.2.1