I have a directory deep in folders (XAMPP) I'd like to cd
into directly into.
I run this in the terminal: CDPATH=/Applications/XAMPP/xamppfiles/htdocs/
And it works!
So if I want this to be permanent, I must add this same line to the .bashrc
file. But adding the same line to my .bashrc
file doesn't work.
My .bashrc
file contains:
[ -n "$PS1" ] && source ~/.bash_profile
CDPATH=/Applications/XAMPP/xamppfiles/htdocs/
How should the line look like in the .bashrc
file? Is mines wrong? I've tried putting export
in front of CDPATH
and also $CDPATH:${HOME}/Applications/XAMPP/xamppfiles/htdocs
but neither works.
First be aware that CDPATH is considered first, hence you will not be able to easily change to a local directory if the other directory contains a directory with the same name. You will probably add an empty path in front, writing CDPATH=:/Application/...
.
You should not need the export
as this one is only relevant for you shell, not for commands run by your shell. The line as you wrote it should be fine.
Be aware that, depending how you start it, bash will read ~/.bashrc
or ~/.bash_profile
. Add an echo
line in both to debug which file is evaluated in your context.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With