Skip to content

Commit

Permalink
Fix issue #79 - expand aliases to detect potentially better ones
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelAquilina committed Oct 13, 2019
1 parent d7ec878 commit fb97694
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tests/test_aliases.zunit
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@
assert $state equals 0
}

@test 'issue 79 - expands aliases' {
@test 'expands aliases to find potentially better matches' {
alias gd='git diff'
alias gdw='git diff --word-diff'
run _check_aliases "gd --word-diff"
run _check_aliases "gd --word-diff" "git diff --word-diff"

assert $output contains 'You should use: "gdw"'
assert $state equals 0
}
}
5 changes: 4 additions & 1 deletion you-should-use.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ function _check_aliases() {
continue
fi

if [[ "$typed" = "$value" || "$typed" = "$value "* ]]; then
if [[ "$typed" = "$value" || \
"$typed" = "$value "* ||
"$expanded" = "$value" || \
"$expanded" = "$value "* ]]; then

# if the alias longer or the same length as its command
# we assume that it is there to cater for typos.
Expand Down

0 comments on commit fb97694

Please sign in to comment.