Skip to content

Commit

Permalink
Basic functions working
Browse files Browse the repository at this point in the history
  • Loading branch information
evilhamsterman committed Mar 20, 2020
1 parent 14b736e commit d7917ce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# fish-sudo
Oh-my-zsh sudo plugin for fish. Modified from https://www.manueluberti.eu/programming/2018/10/27/sudo-fish/
Oh-my-zsh sudo plugin for fish. Modified from https://www.manueluberti.eu/programming/2018/10/27/sudo-fish/.

Press Ctrl+s to prepend sudo to your current command line, or if the command line
is blank prepend it to the previous command in the history.
2 changes: 2 additions & 0 deletions conf.d/fish-sudo.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Prepend sudo with e-e
bind \cs 'prepend_sudo'
11 changes: 11 additions & 0 deletions functions/prepend_sudo.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function prepend_sudo
set -l cmd (commandline)
if test -z "$cmd"
commandline -r $history[1]
end

set -l old_cursor (commandline -C)
commandline -C 0
commandline -i "sudo "
commandline -C (math $old_cursor + 5)
end

0 comments on commit d7917ce

Please sign in to comment.