zle to add sudo (pfexec on solaris) at the beginnig of the line by hitting alt+f

insert-root-prefix () {
   local prefix
   case $(uname -s) in
      "SunOS")
         prefix="pfexec"
      ;;
      *) 
         prefix="sudo"
      ;;
   esac
   BUFFER="$prefix $BUFFER"
   CURSOR=$(($CURSOR + $#prefix + 1))
}

zle -N insert-root-prefix
bindkey "^[f" insert-root-prefix
 
code/zle/addsudoorpfexec.txt · Last modified: 2010/01/05 09:20 (external edit)