From ba5c97d4bf16d0ba9cfcf3d11dee3ce7d5d7a3c1 Mon Sep 17 00:00:00 2001 From: ktdq <105746631+ktdq@users.noreply.github.com> Date: Mon, 26 Feb 2024 18:40:49 -0500 Subject: [PATCH 1/5] Don't change terminal title Changing title is putting extra escape codes and "Julia" into STDOUT and messes up output when used with shell pipes or redirects. --- src/bin/julialauncher.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/bin/julialauncher.rs b/src/bin/julialauncher.rs index 44f15703..cb035b20 100644 --- a/src/bin/julialauncher.rs +++ b/src/bin/julialauncher.rs @@ -283,10 +283,6 @@ fn get_override_channel( } fn run_app() -> Result { - // Set console title - let term = Term::stdout(); - term.set_title("Julia"); - let paths = get_paths().with_context(|| "Trying to load all global paths.")?; do_initial_setup(&paths.juliaupconfig) From 66de0ea184465ff91901fc67422ea62e8a1f6397 Mon Sep 17 00:00:00 2001 From: ktdq <105746631+ktdq@users.noreply.github.com> Date: Mon, 26 Feb 2024 18:46:26 -0500 Subject: [PATCH 2/5] Don't import Term --- src/bin/julialauncher.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/bin/julialauncher.rs b/src/bin/julialauncher.rs index cb035b20..fd0a52de 100644 --- a/src/bin/julialauncher.rs +++ b/src/bin/julialauncher.rs @@ -1,5 +1,4 @@ use anyhow::{anyhow, Context, Result}; -use console::Term; use itertools::Itertools; use juliaup::config_file::{load_config_db, JuliaupConfig, JuliaupConfigChannel}; use juliaup::global_paths::get_paths; From 74ff3946d43b28e5f4031ed0fff0bff59d189993 Mon Sep 17 00:00:00 2001 From: ktdq <105746631+ktdq@users.noreply.github.com> Date: Mon, 26 Feb 2024 19:14:58 -0500 Subject: [PATCH 3/5] Check if the terminal is a TTY and not redirected --- src/bin/julialauncher.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bin/julialauncher.rs b/src/bin/julialauncher.rs index fd0a52de..bb1e7a39 100644 --- a/src/bin/julialauncher.rs +++ b/src/bin/julialauncher.rs @@ -1,4 +1,6 @@ use anyhow::{anyhow, Context, Result}; +use console::Term; +use atty::Stream; use itertools::Itertools; use juliaup::config_file::{load_config_db, JuliaupConfig, JuliaupConfigChannel}; use juliaup::global_paths::get_paths; @@ -282,6 +284,12 @@ fn get_override_channel( } fn run_app() -> Result { + if atty::is(Stream::Stdout) { + // Set console title + let term = Term::stdout(); + term.set_title("Julia"); + } + let paths = get_paths().with_context(|| "Trying to load all global paths.")?; do_initial_setup(&paths.juliaupconfig) From 885fcc40e6412a526f2426440b4ffd98fa3101a5 Mon Sep 17 00:00:00 2001 From: ktdq <105746631+ktdq@users.noreply.github.com> Date: Mon, 26 Feb 2024 19:19:56 -0500 Subject: [PATCH 4/5] rustfmt --- src/bin/julialauncher.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/julialauncher.rs b/src/bin/julialauncher.rs index bb1e7a39..70e43324 100644 --- a/src/bin/julialauncher.rs +++ b/src/bin/julialauncher.rs @@ -1,6 +1,6 @@ use anyhow::{anyhow, Context, Result}; -use console::Term; use atty::Stream; +use console::Term; use itertools::Itertools; use juliaup::config_file::{load_config_db, JuliaupConfig, JuliaupConfigChannel}; use juliaup::global_paths::get_paths; @@ -289,7 +289,7 @@ fn run_app() -> Result { let term = Term::stdout(); term.set_title("Julia"); } - + let paths = get_paths().with_context(|| "Trying to load all global paths.")?; do_initial_setup(&paths.juliaupconfig) From 5aad522ffa851ec00f45aa87ddd577f9180111ef Mon Sep 17 00:00:00 2001 From: ktdq <105746631+ktdq@users.noreply.github.com> Date: Mon, 26 Feb 2024 19:24:44 -0500 Subject: [PATCH 5/5] use is_terminal not atty --- src/bin/julialauncher.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/julialauncher.rs b/src/bin/julialauncher.rs index 70e43324..f7248616 100644 --- a/src/bin/julialauncher.rs +++ b/src/bin/julialauncher.rs @@ -1,6 +1,6 @@ use anyhow::{anyhow, Context, Result}; -use atty::Stream; use console::Term; +use is_terminal::IsTerminal; use itertools::Itertools; use juliaup::config_file::{load_config_db, JuliaupConfig, JuliaupConfigChannel}; use juliaup::global_paths::get_paths; @@ -284,7 +284,7 @@ fn get_override_channel( } fn run_app() -> Result { - if atty::is(Stream::Stdout) { + if std::io::stdout().is_terminal() { // Set console title let term = Term::stdout(); term.set_title("Julia");