9

I constantly need to type:

cd /home/geo/Geant4/geant4.10.00.p02-install/lib/Geant4-10.0.2

How do I create an alias to that directory, so I could just type:

cd $geant (or any other word I decide to create as the alias name)

It would also help me whenever I need to use cmake because I could use $geant as well in the middle of a cmake option.

Thanks.

2
  • uhh sorry. I'm new to ubuntu and those stuff and I didnt know that it was basically the same question
    – Geo
    Jun 23, 2014 at 1:20
  • No problem! askubuntu does this automatically when I mark a question as duplicate to let you know where you find your answer. That's the beauty of it.
    – mniess
    Jun 24, 2014 at 6:54

2 Answers 2

9

Open your $HOME/.bashrc and append:

export GEANT=/home/geo/Geant4/geant4.10.00.p02-install/lib/Geant4-10.0.2

then run source ~/.bashrc and now you schould be able to use it like this:

cd $GEANT
2
  • thank you sir. i have been trying with the alias command, but seems they are only to command
    – Geo
    Jun 22, 2014 at 21:24
  • You are welcome!. I described the way how you can create your own environment variable (more info: askubuntu.com/questions/730/how-do-i-set-environment-variables). Alias do not work in this case (as far as I know).
    – TuKsn
    Jun 22, 2014 at 21:34
1

Just create a link in nautilus, and treat it as a normal folder. Terminal will go straight to it.

8
  • actually I dont mind the "cd" part. i care more about the cmake. i always need to do cmake -dGeant4_DIR=/home/geo/Geant4/geant4.10.00.p02-install/lib/Geant4-10.0.2 and thats a long command which i need to keep looking the full directory everytime i run the program. I'd rather type cmake -DGeant_DIR=$geant.
    – Geo
    Jun 22, 2014 at 21:05
  • I think that will work.
    – Tim
    Jun 22, 2014 at 21:05
  • tried it using cmake. it gave errors when configuring =\
    – Geo
    Jun 22, 2014 at 21:12
  • @Geo Can you show the errors to us?
    – Tim
    Jun 23, 2014 at 8:40
  • sure. After installing Geant4, tried to run an example (B3) with the /home/geo/geant being a link to that big directory i need to use heres the output: imageshack.com/a/img855/4199/dd5n.png
    – Geo
    Jun 23, 2014 at 15:28

Not the answer you're looking for? Browse other questions tagged .