It would be nice to have an option for thefuck to write to stdin instead of using the confirmation prompt, this way the command will appear on a new line and we can edit it if necessary or hit enter to run it.
It would look like this:
$ git stats
git: 'stats' is not a git command. See 'git --help'.
The most similar command is
status
$ fuck
$ git status
Instead of this:
$ git stats
git: 'stats' is not a git command. See 'git --help'.
The most similar command is
status
$ fuck
git status [enter/↑/↓/ctrl+c]
The keystrokes are exactly the same (git stats + ENTER + fuck + ENTER + ENTER)
But this is more convenient if the corrected command needs further fixing.
Kind of how the ^find^replace command works If you know what I'm talking about
$ git stats
git: 'stats' is not a git command. See 'git --help'.
The most similar command is
status
$ ^stats^status
$ git status
That feature is already under development 🙂 Plz check https://github.com/nvbn/thefuck/pull/1063. It would be super nice to read any feedback from you.
Looks nice but opening an editor seems a bit heavy.
This proposal is different in that it spits out the command into the prompt like ^find^replace does (that said, I don't know how ^^ does it).
So I searched a bit online and found that if you put this in your .zshrc (yes this is zsh only), it will output a string directly to the next command line every time you hit '§' (a conveniently placed key with no purpose on my keyboard but could be any key or sequence of keys).
function _fuck_widget {
zle -U "RING RING RING 🍌 ☎️ "
}
zle -N _fuck_widget
bindkey '§' _fuck_widget
The string in our case would be the corrected command.
A weird consequence of the way widgets work in zsh is that it basically only works with keybindings (at least, that's what I've found).
The keystroke would become git stats + ENTER + § [+ ENTER]
The last enter is optional since you can add zle accept-line at the end of the _fuck_widget function to run the line directly (According to the doc but I could not reproduce zle accept-line does nothing).
zle kill-whole-line can also be added to clear the current line before appending the string to the buffer.
If you know how to change the command line buffer from inside a regular function, please let us know.
print -z echo foo does it for Zsh. Only Bash now misses proper support (a.k.a. something other than an editor).
bind '"\e[0n": "echo foo"'; printf '\e[5n' is quite ugly but works in Bash.
print -z echo foo does it for Zsh. Only Bash now misses proper support (a.k.a. something other than an editor).
Oh, when searching, I somehow missed print -z foo (not sure why you put echo here).
It works great 🎉
bind '"\e[0n": "echo foo"'; printf '\e[5n' is quite ugly but works in Bash.
Works on my side too ! 👍
So we have it! YAY
Most helpful comment
So we have it! YAY