Penny
Penny

Reputation: 1280

How to have terminal remember a directory?

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!

Upvotes: 0

Views: 354

Answers (2)

McVenco
McVenco

Reputation: 1009

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

Upvotes: 0

Adam
Adam

Reputation: 495

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

Upvotes: 2

Related Questions