chris
chris

Reputation: 4996

Bash: Is it possible to set an alias with wildcard

Is it possible to include a wildcard in an alias, like:

alias *="echo triggered"

Upvotes: 0

Views: 292

Answers (1)

that other guy
that other guy

Reputation: 123480

No. This would only trigger for a literal asterisk.

If you want to override most commands, you can botch PATH and use command_not_found_handle:

$ PATH=/invalid
$ command_not_found_handle() { echo "triggered"; }
$ man ls
triggered
$ firefox
triggered
$ asdfasdfasdf
triggered

This will not apply to aliases, builtins, or when running commands with full path.

Upvotes: 2

Related Questions