From 8e8a3846fb8bc7dd0dffaf0adce8dae3f78c5bdd Mon Sep 17 00:00:00 2001 From: Johannes Sasongko Date: Mon, 27 Jan 2020 20:32:50 +1000 Subject: [PATCH] __fish_prepend_sudo: Don't move the relative position of the cursor At the moment the "prepend sudo" functionality always sets the cursor to the end of the line. This changes it to restore the relative position of the cursor. --- share/functions/__fish_prepend_sudo.fish | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/functions/__fish_prepend_sudo.fish b/share/functions/__fish_prepend_sudo.fish index aaca6c37a..b681d1ca0 100644 --- a/share/functions/__fish_prepend_sudo.fish +++ b/share/functions/__fish_prepend_sudo.fish @@ -1,8 +1,9 @@ function __fish_prepend_sudo -d "Prepend 'sudo ' to the beginning of the current commandline" set -l cmd (commandline -poc) if test "$cmd[1]" != "sudo" + set -l cursor (commandline -C) commandline -C 0 commandline -i "sudo " - commandline -f end-of-line + commandline -C (math $cursor + 5) end end