I\'m trying to write a small script to change the current directory to my project directory:
#!/bin/bash
cd /home/tree/projects/java
I save
You can create a function like below in your .bash_profile
and it will work smoothly.
The following function takes an optional parameter which is a project. For example, you can just run
cdproj
or
cdproj project_name
Here is the function definition.
cdproj(){
dir=/Users/yourname/projects
if [ "$1" ]; then
cd "${dir}/${1}"
else
cd "${dir}"
fi
}
Dont forget to source your .bash_profile