Being able to mark in an alias definition a point of minimal abbreviation, an old feature of VAX/VMS shell (DCL) would be really nice in modern *nix shells.
In DCL you used to be able to define an alias (in its own weird syntax) which would be something like this:
$ alias fuz*zyanimals="cat dog"
The asterisk marks minimal unique abbreviation for the alias, such that all of the following invocations would work:
Short of forking bash and modifying alias, I don't think there is a way to do what you want. However, this bash function will pollute your environment with lots of aliases. To make things easier I make the assumption that all abbreviations will start at 3 letters and I make no tests for the length of the alias being shorter than 3 letters. Use at your own risk!
nalias() {
local fulline="$*"
local xalias=${fulline#*=}
local name=${fulline%%=*}
local i
for i in $(seq 3 ${#name})
do
alias ${name::$i}="$xalias"
done
}
Example:
$ nalias fuzzyanimals='cat dog'
$ alias | grep fuz
alias fuz='cat dog'
alias fuzz='cat dog'
alias fuzzy='cat dog'
alias fuzzya='cat dog'
alias fuzzyan='cat dog'
alias fuzzyani='cat dog'
alias fuzzyanim='cat dog'
alias fuzzyanima='cat dog'
alias fuzzyanimal='cat dog'
alias fuzzyanimals='cat dog'
$ fuzzyanim
cat: dog: No such file or directory
$
It would probably be possible to add the asterisk marker into the code to split the alias into minimal abbreviation + rest of alias, then add the latter to the former one letter at a time in a similar manner to the above. But this works for the two aliases I tried it on!
nalias() {
local fulline="$*"
local xalias=${fulline#*=}
local name=${fulline%%=*}
local pre=${name%%\**}
local i
[ "$pre" == "$name" ] && name=""
name=${name#${pre}\*}
for((i=0; i <= ${#name}; i++))
do
alias $pre${name:0:$i}=$xalias
done
}
Of course for i in $(seq 0 ${#name}) can be used in place of the above for(( code for more compatibility with older shells, at the cost of some speed.