0

I always have to cd to a very long line of a path in the terminal.

Is there a way to have terminal remember the path, so that I can just type in for example,

cd path1

to get to a very long path cd /Users/user-name/blah/blah/blah/blah/blah/blah ?

I don't really want to use cd -, cause I may switch between several directories.

Thank you very much!

Penny
  • 1,218
  • 1
  • 13
  • 32

2 Answers2

2

You can add:

alias path1='cd /Users/user-name/blah/blah/blah/blah/blah/blah'

to .profile. Then in your terminal you only need to type:

path1
Adam
  • 475
  • 5
  • 18
  • Thank you so much! Can I ask how to add the alias path to the .profile? Sorry for being stupid not knowing this... – Penny Dec 17 '15 at 00:50
  • .profile can be found in "/Users/user-name/". You can open it in any text editor and add the line above. Hope that helps. – Adam Dec 17 '15 at 07:11
  • If you found the answer helpful, could you accept the answer please. – Adam Dec 22 '15 at 19:32
0

If it's just a few directories, you could write aan script for each of them. See this SO answer for example : https://stackoverflow.com/a/874542

Otherwise, maybe a tool like Z could be useful for you?

https://github.com/rupa/z

Community
  • 1
  • 1
McVenco
  • 1,011
  • 1
  • 17
  • 30