From 0c4351aa7c8e3b02b7679af855d75ac1f7a7609f Mon Sep 17 00:00:00 2001 From: manos00 Date: Sun, 9 Jan 2022 01:16:40 +0100 Subject: [PATCH 1/3] added prev command as root functionality --- conf.d/plugin-bang-bang.fish | 4 ++++ functions/__history_previous_command_root.fish | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 functions/__history_previous_command_root.fish diff --git a/conf.d/plugin-bang-bang.fish b/conf.d/plugin-bang-bang.fish index b70c678..4f38659 100644 --- a/conf.d/plugin-bang-bang.fish +++ b/conf.d/plugin-bang-bang.fish @@ -1,14 +1,18 @@ bind ! __history_previous_command bind '$' __history_previous_command_arguments +bind 'S' __history_previous_command_root # set up the same key bindings for insert mode if using fish_vi_key_bindings if test "$fish_key_bindings" = 'fish_vi_key_bindings' bind --mode insert ! __history_previous_command bind --mode insert '$' __history_previous_command_arguments + bind --mode insert S __history_previous_command_root + end function _plugin-bang-bang_uninstall --on-event plugin-bang-bang_uninstall bind --erase --all ! bind --erase --all '$' + bind --erase --all S functions --erase _plugin-bang-bang_uninstall end diff --git a/functions/__history_previous_command_root.fish b/functions/__history_previous_command_root.fish new file mode 100644 index 0000000..16dd004 --- /dev/null +++ b/functions/__history_previous_command_root.fish @@ -0,0 +1,8 @@ +function __history_previous_command_root + switch (commandline -t) + case "!" + commandline -t "sudo $history[1]"; commandline -f repaint + case "*" + commandline -i S + end +end From 8d0aa3bbae60d384682df05b8f52fb16a78cbe49 Mon Sep 17 00:00:00 2001 From: manos00 Date: Sun, 9 Jan 2022 01:36:47 +0100 Subject: [PATCH 2/3] Changes to README.md --- README.md | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 00becf4..514f135 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,12 @@
-This plugin wraps [Aerys Bat's implementation](https://github.com/fish-shell/fish-shell/wiki/Bash-Style-Command-Substitution-and-Chaining-(!!-!%24-&&-%7C%7C)) of bash style history substitution. +This plugin wraps [Aerys Bat's implementation](https://github.com/fish-shell/fish-shell/wiki/Bash-Style-Command-Substitution-and-Chaining-(!!-!$)) of bash style history substitution. ## Install ```fish -$ omf install bang-bang +$ omf install https://github.com/manos00/plugin-bang-bang ``` ## Usage @@ -22,9 +22,9 @@ $ omf install bang-bang `!!` on command line will be replaced by last command issued: ```fish -$ mv /etc/hostname /etc/hostname.old -mv: rename /etc/hostname to /etc/hostname.old: Operation not permitted -$ sudo !! +$ cp ~/.dmrc +cp: missing destination file operand +$ !! cp ~/.dmrc.bak ``` `!$` on command line will be replaced by last command arguments: @@ -34,6 +34,14 @@ $ mkdir /tmp/test $ cd !$ ``` +`!S` on command line will be replaced by "sudo" plus last command: + +```fish +$ mv /etc/hostname /etc/hostname.old +mv: rename /etc/hostname to /etc/hostname.old: Operation not permitted +$ !S +``` + ## Troubleshooting If the keybindings fail to work after installing the plugin, the issue is @@ -45,13 +53,10 @@ plugin `functions/fish_user_key_bindings.fish` file into it. # License -[MIT][mit] © [Aerys Bat][aerys-bat], [Derek Stavis][derekstavis] et [al][contributors] +[MIT][mit] © [original creators][contributors] and [me][manos00] [mit]: http://opensource.org/licenses/MIT -[derekstavis]: http://github.com/derek -[aerys-bat]: https://github.com/AerysBat -[contributors]: https://github.com/derek/plugin-bang-bang/graphs/contributors +[manos00]: https://github.com/manos00 +[contributors]: https://github.com/oh-my-fish/plugin-bang-bang/graphs/contributors [omf-link]: https://www.github.com/oh-my-fish/oh-my-fish - -[license-badge]: https://img.shields.io/badge/license-MIT-007EC7.svg?style=flat-square From e0bf0f56e82302c6faf48ce37a48d4161b407965 Mon Sep 17 00:00:00 2001 From: manos <72750108+manos00@users.noreply.github.com> Date: Sun, 9 Jan 2022 01:40:52 +0100 Subject: [PATCH 3/3] Update README.md smol mistake --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 514f135..0ac8dbf 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ $ omf install https://github.com/manos00/plugin-bang-bang ```fish $ cp ~/.dmrc cp: missing destination file operand -$ !! cp ~/.dmrc.bak +$ !! ~/.dmrc.bak ``` `!$` on command line will be replaced by last command arguments: