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
feature-request: Add fc
"fix command" command, like the shell builtin
#5030
Comments
Fish already has that feature. Simply [up-arrow] or [ctrl-p] to retrieve the command then press [alt-e] or [alt-v]. |
It is documented here: https://fishshell.com/docs/current/index.html#shared-binds But it does not work out of the box in my iTerm2. [alt-e] prints |
@icemac You need to configure iTerm2 to treat [alt] as a meta key that prefixes the sequence with the escape char. Open |
And, of course, you can bind the function to any key of your choosing; e.g., |
@krader1961 Thank you for your tipps. It was the right direction. I eventually found out about |
@krader1961 Thanks, I just tried |
Works for me and everyone else AFAIK. Note that [alt-v] edits the current command. So if you want to edit a previous command you entered you first have to retrieve it such as by pressing [up-arrow]. |
Ah, that was it. I wasn't hitting up-arrow. I suppose this solution works for now. I do think a built-in OR, maybe ship a built-in |
What about people coming from
That is a valid point. Improvements to the documentation are always welcome and arguably more valuable than changes to the implementation. |
I often use fc to re-run several commands again, e.g.
is there any way to achieve that using fish? |
This is useful to combine and rerun several commands. For example having the last 4 commands in $history: $ string join \n $history[1..4] ./test git clean -dfx ls make $ fc -4 -1 opens an editor where you can drop the ls, maybe move the git command to the start, join all lines with '; and' and save. Now the prompt contains one command, ready to be executed. Note that the numbering is inverted to $history to comply with POSIX. The implementation is based on share/functions/edit_command_buffer.fish. fc is specified by POSIX in https://pubs.opengroup.org/onlinepubs/9699919799/utilities/fc.html For now only the first and last options are implemented. Fixes fish-shell#5030
This is useful to combine and rerun several commands. For example having the last 4 commands in $history: $ string join \n $history[1..4] ./test git clean -dfx ls make $ fc -4 -1 opens an editor where you can drop the ls, maybe move the git command to the start, join all lines with '; and' and save. Now the prompt contains one command, ready to be executed. Note that the numbering is inverted to $history to comply with POSIX. The implementation is based on share/functions/edit_command_buffer.fish. fc is specified by POSIX in https://pubs.opengroup.org/onlinepubs/9699919799/utilities/fc.html For now only the first and last options are implemented. Fixes fish-shell#5030
This is useful to combine and rerun several commands. For example having the last 4 commands in $history: $ string join \n $history[1..4] ./test git clean -dfx ls make $ fc -4 -1 opens an editor where you can drop the ls, maybe move the git command to the start, join all lines with '; and' and save. Now the prompt contains one command, ready to be executed. Note that the numbering is inverted to $history to comply with POSIX. The implementation is based on share/functions/edit_command_buffer.fish. fc is specified by POSIX in https://pubs.opengroup.org/onlinepubs/9699919799/utilities/fc.html For now only the first and last options are implemented. Fixes fish-shell#5030
I just learned about the bash builtin
fc
command. It takes the last command and opens it in your editor, so you can tweak it, then when you save it, it runs that new command and adds it to history.Would love to see fish ship this command in core.
The text was updated successfully, but these errors were encountered: