Skip to content

Control-C to simply clear commandline buffer again#10213

Closed
krobelus wants to merge 1 commit into
fish-shell:masterfrom
krobelus:restore-control-c-behavior
Closed

Control-C to simply clear commandline buffer again#10213
krobelus wants to merge 1 commit into
fish-shell:masterfrom
krobelus:restore-control-c-behavior

Conversation

@krobelus
Copy link
Copy Markdown
Contributor

Commit 5f849d0 changed control-C to print an inverted ^C and then a newline.

The original motivation was

In bash if you type something and press ctrl-c then the content of the line
is preserved and the cursor is moved to a new line. In fish the ctrl-c just
clears the line. For me the behaviour of bash is a bit better, because it
allows me to type something then press ctrl-c and I have the typed string
in the log for further reference.

This sounds like a valid use case in some scenarios but I think that most
abandoned commands are noise. After all, the user erased them. Also, undo
can be used to get back a limited set of canceled commands.

I believe the original motivation for existing behavior (in other shells) was
that TERM=dumb does not support erasing characters. Similarly, other shells
like to leave behind other artifacts, for example when using tab-completion
or in their interactive menus but we generally don't.

Control-C is the obvious way to quickly clear a multi-line commandline.
IPython does the same. For the other behavior we have Alt-# although that's
probably not very well-known.

Restore the old Control-C behavior of simply clearing the command line.

Our unused __fish_cancel_commandline still prints the ^C. For folks who
have explicitly bound ^C to that, it's probably better to keep the existing
behavior, so let's leave this one.

Previous attempt at #4713 fizzled.

TODO: changelog, instructions to restore the other behavior.

Commit 5f849d0 changed control-C to print an inverted ^C and then a newline.

The original motivation was

> In bash if you type something and press ctrl-c then the content of the line
> is preserved and the cursor is moved to a new line. In fish the ctrl-c just
> clears the line. For me the behaviour of bash is a bit better, because it
> allows me to type something then press ctrl-c and I have the typed string
> in the log for further reference.

This sounds like a valid use case in some scenarios but I think that most
abandoned commands are noise. After all, the user erased them. Also, undo
can be used to get back a limited set of canceled commands.

I believe the original motivation for existing behavior (in other shells) was
that TERM=dumb does not support erasing characters. Similarly, other shells
like to leave behind other artifacts, for example when using tab-completion
or in their interactive menus but we generally don't.

Control-C is the obvious way to quickly clear a multi-line commandline.
IPython does the same. For the other behavior we have Alt-# although that's
probably not very well-known.

Restore the old Control-C behavior of simply clearing the command line.

Our unused __fish_cancel_commandline still prints the ^C. For folks who
have explicitly bound ^C to that, it's probably better to keep the existing
behavior, so let's leave this one.

Previous attempt at fish-shell#4713 fizzled.

TODO: changelog, instructions to restore the other behavior.
@faho
Copy link
Copy Markdown
Member

faho commented Jan 14, 2024

I'm fine either way. I will note that this is nicer now that we have undo, so you can actually get the old commandline back by pressing ctrl-z.

@zx8
Copy link
Copy Markdown

zx8 commented Jan 15, 2024

My comment in the previous thread is still true today, but as long as "I can simply revert the behaviour to the current behaviour by defining the function in my user config", then I suppose it's fine.

Also, as said, undo didn't exist back then and that's something I use a lot nowadays.

@faho faho added this to the fish next-3.x milestone Jan 16, 2024
@ridiculousfish
Copy link
Copy Markdown
Member

I'm still in favor of this and the undo behavior makes it even more compelling!

@krobelus krobelus closed this in fff8e81 Jan 17, 2024
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jan 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants