I've never gotten into the habit of using aliases for cd-ing into directories, but I use the pushd set of commands so much, I have them shortened to pu, po, and ds (for dirs -v). I don't personally have a huge use for location aliases, as I just use soft links to create shortcuts to them from my home directory. Typing ~/ isn't a huge deal to me.
That said, the "proper" or POSIX-y way to do this is to use the CDPATH variable. Much like you can set your default binary paths with the PATH variable, you can give cd a list of places to look for directories you've asked for. You should usually make . the first directory in CDPATH, but you can add as many additional directories as you like. So in your examples, if you add ~/Documents to your CDPATH, you could get to your projects folder by just typing cd projects from wherever you were. As long as the current directory didn't contain a "projects" folder, you'd be taken to your folder at ~/Documents/projects. The pushd command should obey the CDPATH as well, but I haven't tested it in a while.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I've never gotten into the habit of using aliases for
cd-ing into directories, but I use thepushdset of commands so much, I have them shortened topu,po, andds(fordirs -v). I don't personally have a huge use for location aliases, as I just use soft links to create shortcuts to them from my home directory. Typing~/isn't a huge deal to me.That said, the "proper" or POSIX-y way to do this is to use the
CDPATHvariable. Much like you can set your default binary paths with thePATHvariable, you can givecda list of places to look for directories you've asked for. You should usually make.the first directory inCDPATH, but you can add as many additional directories as you like. So in your examples, if you add~/Documentsto yourCDPATH, you could get to your projects folder by just typingcd projectsfrom wherever you were. As long as the current directory didn't contain a "projects" folder, you'd be taken to your folder at~/Documents/projects. Thepushdcommand should obey theCDPATHas well, but I haven't tested it in a while.