Create an alias to a desired directory to use within the Terminal

10,426

Solution 1

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

Solution 2

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

Share:
10,426

Related videos on Youtube

Geo
Author by

Geo

Updated on September 18, 2022

Comments

  • Geo
    Geo over 1 year

    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.

    • Geo
      Geo almost 10 years
      uhh sorry. I'm new to ubuntu and those stuff and I didnt know that it was basically the same question
    • mniess
      mniess almost 10 years
      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.
  • Geo
    Geo almost 10 years
    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/G‌​eant4-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.
  • Tim
    Tim almost 10 years
    I think that will work.
  • Geo
    Geo almost 10 years
    tried it using cmake. it gave errors when configuring =\
  • Geo
    Geo almost 10 years
    thank you sir. i have been trying with the alias command, but seems they are only to command
  • Tim
    Tim almost 10 years
    @Geo Can you show the errors to us?
  • Geo
    Geo almost 10 years
    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
  • Tim
    Tim almost 10 years
    Tuknutx has the right idea, use that. Sorry mine was wrong...
  • Geo
    Geo almost 10 years
    its cool =) your mode works with a "cd" command, but some programs (or at least geant4) had a problem reading that as a link
  • Tim
    Tim almost 10 years
    Yeah :) An I learnt that I could use them in terminal! :P