When I accidentally type the name of a text file without some kind of editor command, and the text file is not a shell script, I get a "permission denied" error*, since the file is not executable, and the first token in the command line is taken to be the command to execute.
However, invariably this just means that I've inadvertently forgotten to type my editor command, so it would be convenient if the shell could somehow recognize that the first token is an extant text file without the "execute" bit set and automatically open it with either
Is there a way to accomplish this in Bash or Zsh? (I use Bash but am thinking of switching anyway.) It would be a little like Bash's
autocd option, which automatically detects whether the first token is a directory and attempts to
cd into it rather than giving the standard "Is a directory" error.
Ideally, if I give a list of files (e.g. with a glob) or any other set of arguments, all of these arguments would be passed to the editor command.
* Of course I can also get a "command not found" error if I'm specifying a file in the current directory without