Mac terminal cd to folder IN current directory

Let say my current directory in terminal is ~/Users/Desktop. On my desktop, there's a folder called "sample_dir". How can I cd in this "sample_dir" folder with typing: "cd ~/Users/Desktop/sample_dir"? There's gotta be a shorter way that looks at your current directory and appends that path to the directory you pass in to make things faster.

Thanks


There is. Type:

cd sample_dir

It checks for you. If for some strange reason that doesn't work, type:

cd ./sample_dir

I usually type cd, then drag the folder (from Finder) that I want to open in Terminal, and drop it in Terminal. This will add the full directory path, then press enter to change to the dropped directory.


The path you are using cd ~/Users/Desktop/sample_dir is wrong.

If you have a folder named sample_dir in you user's Desktop directory then the full path to the directory is:

cd /Users/YourUserName/Desktop/sample_dir

Where YourUserName is the the short account username. Using the tilde ~ shortcut to your home directory this can be shortened to

cd ~/Desktop/sample_dir

When you open a new terminal session you start in your home directory, so:

cd Desktop/sample_dir

Typing cd sample_dir should work... check "pwd" to make sure the current path is what you expect.