diff options
author | Bodigrim <andrew.lelechenko@gmail.com> | 2023-02-04 00:18:44 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-02-04 18:48:32 -0500 |
commit | 5a54ac0b2b915889950c83e04bf1beb08631891e (patch) | |
tree | 792b4c63a442d22c799bb1d04f6779737f97933b /utils | |
parent | 7612dc713d5a1f108cfd6eb731435b090fbb8809 (diff) | |
download | haskell-5a54ac0b2b915889950c83e04bf1beb08631891e.tar.gz |
Fix colors in emacs terminal
Diffstat (limited to 'utils')
-rw-r--r-- | utils/ghc-pkg/Main.hs | 6 |
1 files changed, 4 insertions, 2 deletions
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 () |