mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2024-11-23 13:16:43 +08:00
Merge pull request #394 from daveyarwood/better-alias-fix
Fix for better-alias plugin
This commit is contained in:
commit
2861456956
|
@ -1,11 +1,10 @@
|
|||
function balias --argument alias command
|
||||
eval 'alias $alias $command'
|
||||
if expr match $command '^sudo '>/dev/null
|
||||
set command (expr substr + $command 6 (expr length $command))
|
||||
if expr $command : '^sudo '>/dev/null
|
||||
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
|
||||
|
||||
|
|
36
plugins/better-alias/balias.spec.fish
Normal file
36
plugins/better-alias/balias.spec.fish
Normal file
|
@ -0,0 +1,36 @@
|
|||
import plugins/fish-spec
|
||||
import plugins/balias
|
||||
|
||||
function describe_library -d "better-alias"
|
||||
|
||||
function after_all
|
||||
functions -e changedir
|
||||
functions -e ls_as_root
|
||||
end
|
||||
|
||||
function it_doesnt_fail
|
||||
balias changedir cd
|
||||
expect test $status --to-be-true
|
||||
end
|
||||
|
||||
function it_defines_an_alias
|
||||
functions changedir
|
||||
expect test $status --to-be-true
|
||||
end
|
||||
|
||||
function you_can_use_the_alias
|
||||
mkdir testdir
|
||||
changedir testdir
|
||||
expect test $status --to-be-true
|
||||
cd ..
|
||||
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
|
Loading…
Reference in New Issue
Block a user