fish-shell / fish-shell

The user-friendly command line shell.

Home Page:https://fishshell.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terminal protocols spew a *lot* of output

faho opened this issue · comments

We now enable "terminal protocols", like bracketed paste, CSI u key codes etc.

This was always going to lead to more output to the terminal, which is overall fine - we've always been pretty chatty (highlighting, suggestions, etc).

But I think the current state may be a bit much. It'll not only adversely impact performance (especially over ssh), but is also in the way when you look at a log like with script or asciinema.

As it stands, starting fish --no-config and running echo foobar prints on the order of ~1500 bytes (3.7.1 does ~800 bytes) - counted with script and wc -c.

In particular, it will apparently enable and disable protocols multiple times before it even gets to the input - I count 8 times before it gets to the prompt (in --no-config mode).

Most of this is down to toggling it in parser::eval_node:

fish-shell/src/parser.rs

Lines 565 to 581 in e7f13ac

// If interactive or inside noninteractive builtin read.
let terminal_protocols_enabled = TERMINAL_PROTOCOLS.get().borrow().is_some();
let terminal_protocols_disabled =
terminal_protocols_enabled.then(terminal_protocols_disable_scoped);
// Check the exec count so we know if anything got executed.
let prev_exec_count = self.libdata().pods.exec_count;
let prev_status_count = self.libdata().pods.status_count;
let reason =
self.execution_context()
.as_ref()
.unwrap()
.eval_node(&op_ctx, node, Some(scope_block));
let new_exec_count = self.libdata().pods.exec_count;
let new_status_count = self.libdata().pods.status_count;
drop(terminal_protocols_disabled);

Remove it and we're down to ~980 bytes, which would be reasonable.

@krobelus Is that one necessary? Is there a better spot to put it? It strikes me as suspect to do it there.