From 555eba3b6f55da63c73053b8a4fb11dbd18a3031 Mon Sep 17 00:00:00 2001 From: Anas Elgarhy Date: Thu, 25 Aug 2022 10:36:04 +0200 Subject: [PATCH] =?UTF-8?q?Add=20!!=20and=20!$=20to=20fish=20yo=20?= =?UTF-8?q?=F0=9F=98=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/fish/functions/functions.fish | 1 + .config/fish/functions/history.fish | 28 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 .config/fish/functions/history.fish diff --git a/.config/fish/functions/functions.fish b/.config/fish/functions/functions.fish index 6dccb0f..1e29506 100644 --- a/.config/fish/functions/functions.fish +++ b/.config/fish/functions/functions.fish @@ -1 +1,2 @@ source $HOME/.config/fish/functions/take_skip.fish +source $HOME/.config/fish/functions/history.fish diff --git a/.config/fish/functions/history.fish b/.config/fish/functions/history.fish new file mode 100644 index 0000000..2237c5f --- /dev/null +++ b/.config/fish/functions/history.fish @@ -0,0 +1,28 @@ +# Functions needed for !! and !$ +function __history_previous_command + switch (commandline -t) + case "!" + commandline -t $history[1]; commandline -f repaint + case "*" + commandline -i ! + end +end + +function __history_previous_command_arguments + switch (commandline -t) + case "!" + commandline -t "" + commandline -f history-token-search-backward + case "*" + commandline -i '$' + end +end +# The bindings for !! and !$ +if [ "$fish_key_bindings" = "fish_vi_key_bindings" ]; + bind -Minsert ! __history_previous_command + bind -Minsert '$' __history_previous_command_arguments +else + bind ! __history_previous_command + bind '$' __history_previous_command_arguments +end +