Skip to content

Commit

Permalink
Add __fish_prepend_sudo function and binding
Browse files Browse the repository at this point in the history
This can be removed if/when [1] is merged

[1]: fish-shell/fish-shell#6140
  • Loading branch information
gpanders committed Sep 26, 2019
1 parent 1b109e5 commit 3214f05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fish/.config/fish/config.fish
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
bind \ew __fish_whatis_current_token
bind -M insert \ew __fish_whatis_current_token

bind \es __fish_prepend_sudo
bind -M insert \es __fish_prepend_sudo
8 changes: 8 additions & 0 deletions fish/.config/fish/functions/__fish_prepend_sudo.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function __fish_prepend_sudo -d "Prepend 'sudo ' to the beginning of the current commandline"
set -l cmd (commandline -boc)
if test "$cmd[1]" != "sudo"
commandline -C 0
commandline -i "sudo "
commandline -f end-of-line
end
end

0 comments on commit 3214f05

Please sign in to comment.