Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I found a solution to another question and posted here and wanted to implement it.

On OSX, in order to create cd shortcuts, it advised creating a hidden folder with symbolic links, and then adding that to the CDPATH variable. Well, I tried, and I am kind of a UNIX rookie so I'm coming for advice.

Here's what I did:

mkdir ~/.shortcuts   
ln -s /mydir/here/ ~/.shortcuts/mydir    
open ~/.bashrc    

add this line :

export CDPATH=.:~/.shortcuts

close all Terminal windows and re-open then tried the shortcut cd mydir

Can you see what I am missing?

share|improve this question
    
Can you try replacing the ~ with /home/user? I.e. replace the relative path with the absolute path in the definition of CDPATH. –  darthbith Sep 26 '13 at 19:37
    
Modified it to export CDPATH=.:~:/Users/amejia/.shortcuts and no dice. I'm reading up on CDPATH i think my syntax may be off? –  sweeds Sep 26 '13 at 19:41
    
Did it work? If not, add the directory that cd ~ takes you to to replace the ~ in the path. If it did, awesome :-) –  darthbith Sep 26 '13 at 19:43
    
Is this an OSX system by any chance? –  terdon Sep 26 '13 at 23:46

2 Answers 2

up vote 0 down vote accepted

It looks like you are using OSX, as far as I know open is specific to macs, in the Linux world you have xdg-open. Please make sure to always mention your exact operating system in your question.

Now, assuming you are indeed using OSX, the file you should edit is ~/.bash_profile and not ~/.bashrc. The OSX terminal app starts login shells by default and these do not read ~/.bashrc. Also, it is generally good practice to always quote variable declarations. So, open ~/.bash_profile and add this line:

export CDPATH=".:~/.shortcuts"

Also, you don't need the link, you can simply add the directories you want to the $CDPATH varilable:

export CDPATH=".:/mydir/here/:/mydir/there/:/mydir/everywhere/"
share|improve this answer
    
using .bash_profle was the solution. I'll take note of your other advice, and make sure to specify OS. Ty. –  sweeds Sep 27 '13 at 17:25

Once I found the problem described by @terdon, using an Alias was a much simpler solution.

In .bash_profile: alias go-myDir="cd /Volumes/Active/Dir"

Now, typing go-myDir in the Terminal, is a shortcut for the entire cd command

Improving Terminal workflow with Alias

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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