diff --git a/console/src/main/java/org/jline/console/impl/SystemRegistryImpl.java b/console/src/main/java/org/jline/console/impl/SystemRegistryImpl.java index 4c476a5ca..6d0cc918a 100644 --- a/console/src/main/java/org/jline/console/impl/SystemRegistryImpl.java +++ b/console/src/main/java/org/jline/console/impl/SystemRegistryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2021, the original author or authors. + * Copyright (c) 2002-2022, the original author or authors. * * This software is distributable under the BSD license. See the terms of the * BSD license in the documentation provided with this software. @@ -472,7 +472,7 @@ public void redirect(File file, boolean append) throws IOException { outputStream = new FileOutputStream(file, append); } - public void open() throws IOException { + public void open(boolean redirectColor) throws IOException { if (redirecting || outputStream == null) { return; } @@ -490,9 +490,8 @@ public void open() throws IOException { terminal = TerminalBuilder.builder() .streams(in, outputStream) .attributes(attrs) - .jna(false) - .jansi(false) - .type(Terminal.TYPE_DUMB).build(); + .type((redirectColor ? Terminal.TYPE_DUMB_COLOR : Terminal.TYPE_DUMB)) + .build(); this.commandSession = new CommandRegistry.CommandSession(terminal, terminal.input(), out, out); redirecting = true; } catch (IOException e) { @@ -1176,7 +1175,7 @@ public Object execute(String line) throws Exception { } else if (consoleId != null) { outputStream.redirect(); } - outputStream.open(); + outputStream.open(consoleOption("redirectColor", false)); } boolean consoleScript = false; try {