From 5655a90a28e2a286ae763c9fa7afe88c09a77920 Mon Sep 17 00:00:00 2001 From: Kevin Song Date: Mon, 27 Jan 2020 17:23:08 -0600 Subject: [PATCH] fix: Restrict clear screen control code printing to fish (#865) Wraps clearscreen print codes in a statement to detect fish shell, since it is a workaround for a fish shell behavior. --- src/print.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/print.rs b/src/print.rs index 46d44d22..b7b2936a 100644 --- a/src/print.rs +++ b/src/print.rs @@ -5,7 +5,7 @@ use std::fmt::Write as FmtWrite; use std::io::{self, Write}; use unicode_width::UnicodeWidthChar; -use crate::context::Context; +use crate::context::{Context, Shell}; use crate::module::Module; use crate::module::ALL_MODULES; use crate::modules; @@ -26,7 +26,11 @@ pub fn get_prompt(context: Context) -> String { writeln!(buf).unwrap(); } - buf.push_str("\x1b[J"); + // A workaround for a fish bug (see #739,#279). Applying it to all shells + // breaks things (see #808,#824,#834). Should only be printed in fish. + if let Shell::Fish = context.shell { + buf.push_str("\x1b[J"); // An ASCII control code to clear screen + } let modules = compute_modules(&context);