fix for sudo command aliases

This commit is contained in:
Dave Yarwood 2015-03-01 09:20:42 -05:00
parent 849fcbecc8
commit 14902584f5
2 changed files with 7 additions and 2 deletions

View File

@ -1,11 +1,10 @@
function balias --argument alias command
eval 'alias $alias $command'
if expr $command : '^sudo '>/dev/null
set command (expr substr + $command 6 (expr length $command))
set command (echo "$command" | cut -c6-)
end
complete -c $alias -xa "(
set -l cmd (commandline -pc | sed -e 's/^ *\S\+ *//' );
complete -C\"$command \$cmd\";
)"
end

View File

@ -5,6 +5,7 @@ function describe_library -d "better-alias"
function after_all
functions -e changedir
functions -e ls_as_root
end
function it_doesnt_fail
@ -25,6 +26,11 @@ function describe_library -d "better-alias"
rmdir testdir
end
function it_chops_off_sudo
balias ls_as_root 'sudo ls'
expect test $status --to-be-true
end
end
spec.run $argv