Is it possible for bash to find commands in a case-insensitive way?
eg. these command lines will always run python:
python
Python
PYTHON
pyThoN
bashcase sensitivitycommand line
Is it possible for bash to find commands in a case-insensitive way?
eg. these command lines will always run python:
python
Python
PYTHON
pyThoN
Best Answer
One way is to use
alias
shell builtin, for example:For a better approach, the
command_not_found_handle()
function can be used as described in this post: regex in alias. For instance, this will force all the commands to lowercase:Unfortunately it does not work with builtin commands like
cd
.Also (if you have Bash 4.0) you can add a tiny function in your
.bashrc
to convert uppercase commands to lowercase before executing them. Something similar to this:Then you can run the command by calling
: Python
in command line.NB as @cas mentioned in the comments, : is a reserved bash word. So to avoid inconsistencies and issues you can replace it with
c
or something not already reserved.