In the terminal You use cd ../../........ to get to wherever you want,

But I am lazy, I am wondering if it is possible to automatically cd into the directories if the command is simply the directory.

The terminals obviously know it's the directory because you get the output of

$ ../
bash: ../: Is a directory

So is it possible to hijack this message to automatically cd into that directory?

  • lol that is lazy. Just be careful some direcotires and executables share the same name, that's why typing cd is better. – coteyr May 20 '13 at 23:07
  • 1
    laziness is a virtue – valbaca Jul 1 '16 at 23:25

Add shopt -s autocd to your ~/.bashrc.

Also, you might want to run man shopt in terminal for more useful options.

  • Yes. This Works perfectly. I can also use cd foldername in order to change directory in the common way but, how can I remove such functionality and revert to default? Thanks in advance. – Geppettvs D'Constanzo May 20 '13 at 23:23
  • shopt -u autocd -- read the link man. – coteyr May 20 '13 at 23:38
  • 1
    info bash --index-search='shopt' or Gnu Bash Reference - Shopt – LantzR May 20 '13 at 23:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.