The thing is that sometimes I type cd
by mistake and that take me to the home directory.
e.g. I'm in a directory that have a hidden directory and a visible directory, I quickly press cd
+tab and that takes me to the home directory
The thing is that sometimes I type cd
by mistake and that take me to the home directory.
e.g. I'm in a directory that have a hidden directory and a visible directory, I quickly press cd
+tab and that takes me to the home directory
Use
gedit ~/.bashrc
and insert these lines at the bottom:Open a new terminal and now when you type
cd
with no parameters you simply stay in the same directory.TL;DR
If you want to be really elaborate you can put in a help screen when no parameters are passed:
The expanded code to accomplish this is:
If it's tab completion that's causing this, one option is to make the completion cycle through entries immediately. This can be done using readline's
menu-comple
option instead of the defaultcomplete
:Then, in my home directory, for example:
Of course, even then you'd have to read what you're executing.
Here's how I put the current dir and user in my windows title - You can adapt it to your need, but
cd -
, equivalent tocd $OLDPWD
is a better solution.From my
~/.bashrc
:The problem here is not
cd
, and it's not fixed by technology.The problem is you, and it's fixed by patience!
If you frequently find yourself typing and submitting commands that you did not want, practice slowing down. Take a breath, read what you're typing, and double-check it before pressing enter. Think it through. Don't rush.
You'll find that this approach not only solves the problem at hand, but other far worse problems that you are going to encounter if you continue down your current path.