Let __fish_prepend_sudo use the last commandline if there is no current one (#7079)

* docs/faq: Mention prepend_sudo

[ci skip]

* __fish_prepend_sudo: Use $history[1] if commandline is empty

Currently, if you press alt+s with an empty commandline, it inserts
"sudo", which seems fairly useless.

Now, it inserts "sudo " followed by the last history entry, which
makes it a replacement for `sudo !!`.

* docs
This commit is contained in:
Fabian Homborg
2020-06-04 18:25:02 +02:00
committed by GitHub
parent 3692d63188
commit e646285bcb
3 changed files with 7 additions and 3 deletions

View File

@@ -1431,7 +1431,7 @@ Some bindings are shared between emacs- and vi-mode because they aren't text edi
- :kbd:`Alt`\ +\ :kbd:`V` Same as :kbd:`Alt`\ +\ :kbd:`E`.
- :kbd:`Alt`\ +\ :kbd:`S` Prepends `sudo` to the current commandline.
- :kbd:`Alt`\ +\ :kbd:`S` Prepends `sudo` to the current commandline. If the commandline is empty, prepend `sudo` to the last commandline.
- :kbd:`Control`\ +\ :kbd:`Space` Inserts a space without expanding an :ref:`abbreviation <abbreviations>`. For vi-mode this only applies to insert-mode.