How to make almost all Linux files management such as finding, auto-completion, etc, case-insensitive but its shell/Bash copy and move command 'cp', 'mv' to be case-sensitive?
How to make almost all Linux files management such as finding, auto-completion, etc, case-insensitive but its shell/Bash copy and move command 'cp', 'mv' to be case-sensitive?
You mentioned finding files and autocompletion as examples of where you desire case-insensitivity, but even if these are the only things that are case-insensitive--specifically, the
find
command and your shell's tab completion--you can get nearly all the effect of having most actions you perform from the shell be case-insensitive when you want them to be.The reason is that there are three major situations where you enter the name of a file in a shell:
find
for this, you can just tell it to search case-insensitively. Usually this consists of replacing the-name
test with the-iname
test.Although
/bin/sh
in Ubuntu is provided bydash
, the default user shell--the one you get when you log in non-graphically or open a terminal--isbash
. Most Ubuntu users usebash
. Since it's the most popular shell in Ubuntu and you've tagged this question bash, I'm guessing you use it. Note that the way you would make another shell (such aszsh
) use case-insensitive tab completion is usually different (and some shells can't, or don't even have tab completion at all).The way I recommend you make
bash
perform case-insensitive tab completion is first to try it out in a currently running shell by running the command:After running that command, both the names of commands and the names of their filename arguments are subject to case insensitive tab completion. Although this does apply in commands like
cp
andmv
, it only happens when you press Tab to perform the completion. Whatever text appears in a command, whether you write it or is produced by tab completion, is the text from which the arguments to the command are parsed. Therefore you always have full yet efficient control of what is and is not case-insensitive.I don't claim this is the only or even necessarily an ideal solution, but it's a quite general and safe solution. (You might eventually want to customize tab completion further by writing custom rules for commands where you don't want it to be case insensitive.)
After you try out case-insensitive tab completion and decide you want it on all the time, you can enable it permanently--or until you decide to undo the change--by adding that same
bind
line to the end of your~/.bashrc
file. As init3 says you can do this either with a shell command or in a text editor:(That's from init3's answer to Can I make Tab auto-completion case-insensitive in Bash? That question shows some other ways to enable case-insensitive tab completion in
bash
, if you're interested.)