mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-05 16:21:15 -03:00
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:
@@ -226,7 +226,9 @@ Change the value of the variable ``fish_greeting`` or create a ``fish_greeting``
|
||||
|
||||
Why doesn't history substitution ("!$" etc.) work?
|
||||
--------------------------------------------------
|
||||
Because history substitution is an awkward interface that was invented before interactive line editing was even possible. Instead of adding this pseudo-syntax, fish opts for nice history searching and recall features. Switching requires a small change of habits: if you want to modify an old line/word, first recall it, then edit. E.g. don't type "sudo !!" - first press Up, then Home, then type "sudo ".
|
||||
Because history substitution is an awkward interface that was invented before interactive line editing was even possible. Instead of adding this pseudo-syntax, fish opts for nice history searching and recall features. Switching requires a small change of habits: if you want to modify an old line/word, first recall it, then edit.
|
||||
|
||||
Most of the time, it's used as ``sudo !!``. In that case just press :kbd:`Alt`\ +\ :kbd:`S`, and it will recall your last commandline with `sudo` prefixed (or toggle a `sudo` prefix on the current commandline if there is anything).
|
||||
|
||||
Fish's history recall is very simple yet effective:
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user