mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-20 21:02:59 +08:00
8e8a3846fb
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.
10 lines
309 B
Fish
10 lines
309 B
Fish
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 -C (math $cursor + 5)
|
|
end
|
|
end
|