-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Space in prompt after ctrl-D while running command #8871
Comments
bisects to 8ddd512 (Refine when we expand abbreviations, 2020-03-19), which added
so a workaround is |
Where does the translation of I think we can fix this by using bind -k nul "abbr -q (commandline -t) && commandline -i ' '" Actually, perhaps it's better ergonomics to always emit a space for |
no idea :(
good idea, let's do that for now (it's simpler hence more predictable) |
My guess: This isn't about reading ctrl-d, it's about reading EOF (do So we get an empty read before we reset the terminal modes to our internal ones, and we're missing a check for the empty string somewhere. It's probably okay to ignore it - we'd otherwise have to translate it back from the EOF char, and that depends on the current exact terminal modes and that's racy. |
Thanks a lot! That workaround should indeed work this situation, I think. (Hard to test on an old fish that doesn't support $() yet.) Though I would also be curious whether @faho's predicted root cause is correct. :) |
try
|
Ooh, a magic builtin! Binding works and fixes the issue. :) Also I could have been less lazy and tested it on a command line without newlines... |
Pressing Ctrl-D while a command is running results in a null key code in our input queue. That key code is bound to insert a space (without expanding abbreviations). Make it only insert a space if the commandline is non-empty, to accommodate this use case. This probably affects other keys as well. Closes fish-shell#8871
I normally use ctrl-D to exit fish; this works only on an empty prompt, as expected. However, sometimes I am too early with hitting ctrl-D, and enter it already while a command is still running. (My intention is then to exit the shell directly after the command; incidentally, this is often
git push
.) In this situation, not only does the ctrl-D not result in closing the shell, it also puts a single space character in the prompt buffer so that I have to type another backspace and then another ctrl-D to actually exit the shell.I'm not sure whether it is a good idea for the shell to exit if a ctrl-D is already in the buffer when a command exits; exiting the shell is a somewhat destructive action. However, I do think that the space character should not be there.
Bash does not have this behaviour; the prompt input is empty after a command exits.
Recording: https://asciinema.org/a/486924 (Easy reproduction: run
sleep 2
, press ctrl-D while the command runs, and observe a space character in the prompt input.)System:
fish --version
-> 3.3.1uname -a
=Linux arrow 5.16.16-arch1-1 #1 SMP PREEMPT Mon, 21 Mar 2022 22:59:40 +0000 x86_64 GNU/Linux
$TERM
=tmux-256color
sh -c 'env HOME=$(mktemp -d) fish'
has the same behaviour, as shown in the asciinema recording.The text was updated successfully, but these errors were encountered: