Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Alias for programs

  1. #1
    Join Date
    Oct 2014
    Location
    Switzerland
    Posts
    411

    Default Alias for programs

    Hello,

    I was wondering if someone could tell me how to set up an alias for a data analysis tool.

    With Python,
    typing python from terminal gives me python 2.7*
    typing python3 from terminal gives me python 3.*

    I have a data analysis tool that I learned to compile from the source, by editing my .bashrc

    typing root form terminal gives me root-5.35-*
    now they came up with a new version ROOT 6.02*,

    ROOT 6.02 does not sit well with my older codes because of the differences in declaration of pointers.
    a.that() needs to be all swapped to
    a->that(), and I'm sure that there are some other things that I am yet to notice. In short scripts that I've already written which plays nice with ROOT 5.34 does NOT play nice with ROOT 6.02

    I wish to set things up such that
    if I type
    root, it brings up ROOT 5.*
    and root6 giving me ROOT6.*

    any idea/suggestions?

    Thank you for your time
    -SJL

  2. #2
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,131

    Default Re: Alias for programs

    You can put alias statements in the file .alias in your home directory (~/.alias). Because
    Code:
    henk@boven:~> grep alias .bashrc
    test -s ~/.alias && . ~/.alias || true
    henk@boven:~>
    the aliases will be available in all bash sessions you start after doing his.
    Henk van Velden

  3. #3

    Default Re: Alias for programs

    Quote Originally Posted by SJLPHI View Post
    Hello,

    I was wondering if someone could tell me how to set up an alias for a data analysis tool.

    With Python,
    typing python from terminal gives me python 2.7*
    typing python3 from terminal gives me python 3.*

    I have a data analysis tool that I learned to compile from the source, by editing my .bashrc

    typing root form terminal gives me root-5.35-*
    now they came up with a new version ROOT 6.02*,

    ROOT 6.02 does not sit well with my older codes because of the differences in declaration of pointers.
    a.that() needs to be all swapped to
    a->that(), and I'm sure that there are some other things that I am yet to notice. In short scripts that I've already written which plays nice with ROOT 5.34 does NOT play nice with ROOT 6.02

    I wish to set things up such that
    if I type
    root, it brings up ROOT 5.*
    and root6 giving me ROOT6.*

    any idea/suggestions?

    Thank you for your time
    -SJL

    Hi,

    as Henk pointed out you can put your alias in ~/.alias but it can be in ~/.bashrc as well since ~/.alias is just being sourced by ~/.bashrc

    Another option is to put that compiled? binary/executable in

    Code:
    ~/bin
    for single user setup

    for system wide setup you can put it in

    Code:
    /usr/local/bin
    You can checkout that PATH by

    Code:
    echo "$PATH"
    And the output is like this on my side.
    Code:
    /home/jetchisel/bin /usr/local/bin /usr/bin /bin /usr/bin/X11 /opt/kde3/bin
    The order is important because the binary/executable is being search in your path from left to right so if when you type your program and the system finds it in ~/bin then that is used if not then the search continues.

    The caveat of using ~/.bashrc for your aliases is it assumes you are using bash as your log-in shell.
    For system wide aliases you can put it in (non-existent)

    Code:
    /etc/bash.bahsrc.local
    Again it assumes bash as the log in shell for all users.
    "Unfortunately time is always against us" -- [Morpheus]

    .:https://github.com/Jetchisel:.

  4. #4
    Join Date
    Oct 2014
    Location
    Switzerland
    Posts
    411

    Default Re: Alias for programs

    Thank you for the replies,
    so I currently have my ROOT 5.34 compiled in
    ~/ROOT
    and ROOT 6.02 compiled in
    ~/ROOT6,

    what could I write in .alias or .bashrc
    to make "root" to refer to ROOT5.34 and "root6" to refer to ROOT6.02?

  5. #5
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,131

    Default Re: Alias for programs

    1) Please do show us things. E.g. do not tell a story about ROOT being in ~/ROOT, but post what happens when you do
    Code:
    ls -l ~/ROOT
    Copy/paste computer text complete (that is prompt, command, output and next prompt) in one sweep between CODE tags in your post. You get the CODE tags by clicking on the # button in the tool bar of the post editor.

    2) I never would put such programs dircetly in my home directory. You better organise things in using separte directories for separate things. In this case there is already a directory bin in your home directory. So better move ROOT and ROOT6 there: ~/bin/ROOT and ~/bin/ROOT6. This has the advantage that ~/bin is in your PATH environment variable and will thus be found if you simply call it as
    Code:
    ROOT
    from whichever working directory you happen to be.

    3) Check if you, the owner, can excute it. In other words the x-bit for owner must be set. When not do
    Code:
    cd ~/bin
    chmod u+x ROOT ROOT6
    4) Now it eems that you do not want to call it as
    Code:
    ROOT
    ROOT6
    but as
    Code:
    root
    root6
    There are three (3) solutions here:

    a) change the name of the files:
    Code:
    cd ~/bin
    mv ROOT root
    mv ROOT6 root6
    b) when you do not like that, make hard links:
    Code:
    cd ~/bin
    ln ROOT root
    ln ROOT6 root6
    3) or create aliases in ~../alias by using the editor you love to create (or edit when it is already there) ~/.alias and ad the lines:
    Code:
    alias root='ROOT'
    alias root6='ROOT6'
    Henk van Velden

  6. #6
    Join Date
    Oct 2014
    Location
    Switzerland
    Posts
    411

    Default Re: Alias for programs

    Code:
    ~> ls -l ~/ROOTtotal 904
    drwxr-xr-x  2 sjl users   4096 Dec 21 19:38 bin
    drwxr-xr-x  5 sjl users   4096 Dec  2 12:12 bindings
    drwxr-xr-x  7 sjl users   4096 Dec 21 19:06 build
    drwxr-xr-x 13 sjl users   4096 Dec  2 12:12 cint
    drwxr-xr-x  4 sjl users   4096 Dec  2 12:12 cmake
    -rw-r--r--  1 sjl users   8465 Dec  2 12:12 CMakeLists.txt
    drwxr-xr-x  2 sjl users   4096 Dec 21 19:06 config
    -rw-r--r--  1 sjl users 297396 Dec 21 19:06 config.log
    -rw-r--r--  1 sjl users    278 Dec 21 19:06 config.status
    -rwxr-xr-x  1 sjl users 277179 Dec  2 12:12 configure
    drwxr-xr-x 19 sjl users   4096 Dec  2 12:12 core
    drwxr-xr-x 10 sjl users   4096 Dec  2 12:12 doc
    drwxr-xr-x  8 sjl users   4096 Dec  2 12:12 documentation
    drwxr-xr-x  9 sjl users   4096 Dec 21 19:06 etc
    drwxr-xr-x  2 sjl users   4096 Dec  2 12:12 fonts
    drwxr-xr-x  7 sjl users   4096 Dec  2 12:12 geom
    drwxr-xr-x 18 sjl users   4096 Dec  2 12:12 graf2d
    drwxr-xr-x 10 sjl users   4096 Dec  2 12:12 graf3d
    drwxr-xr-x 12 sjl users   4096 Dec  2 12:12 gui
    drwxr-xr-x  8 sjl users   4096 Dec  2 12:12 hist
    drwxr-xr-x  5 sjl users   4096 Dec  2 12:12 html
    drwxr-xr-x  2 sjl users  20480 Dec  2 12:12 icons
    drwxr-xr-x 11 sjl users  65536 Dec 21 19:06 include
    drwxr-xr-x 13 sjl users   4096 Dec  2 12:12 io
    drwxr-xr-x  3 sjl users  20480 Dec 21 19:38 lib
    -rw-r--r--  1 sjl users  26210 Dec  2 12:12 LICENSE
    drwxr-xr-x  2 sjl users   4096 Dec 21 19:06 macros
    drwxr-xr-x  3 sjl users   4096 Dec  2 12:12 main
    -rw-r--r--  1 sjl users  53611 Dec 21 19:06 Makefile
    drwxr-xr-x  3 sjl users   4096 Dec  2 12:12 man
    drwxr-xr-x 21 sjl users   4096 Dec  2 12:12 math
    drwxr-xr-x  8 sjl users   4096 Dec  2 12:12 misc
    drwxr-xr-x  7 sjl users   4096 Dec  2 12:12 montecarlo
    drwxr-xr-x 19 sjl users   4096 Dec  2 12:12 net
    drwxr-xr-x 10 sjl users   4096 Dec  2 12:12 proof
    drwxr-xr-x  2 sjl users   4096 Dec  2 12:12 README
    drwxr-xr-x  7 sjl users   4096 Dec  2 12:12 roofit
    drwxr-xr-x  3 sjl users   4096 Dec  2 12:12 rootx
    drwxr-xr-x  9 sjl users   4096 Dec  2 12:12 sql                                                                                                              
    drwxr-xr-x  9 sjl users   4096 Dec  2 12:12 test                                                                                                             
    drwxr-xr-x  6 sjl users   4096 Dec  2 12:12 tmva                                                                                                             
    drwxr-xr-x  6 sjl users   4096 Dec  2 12:12 tree                                                                                                             
    drwxr-xr-x 43 sjl users   4096 Dec 22 14:18 tutorials

  7. #7
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,131

    Default Re: Alias for programs

    I think I am completley misunderstanding you.

    From your posts I understood that you have executable files ~/ROOT and ~/ROOT6.

    The above shows that ~/ROOT is a directory containing the unpacked tarball.

    Thus we have to start all over in understanding what you mean.
    Not much time at the moment and it looks as I have to formulate some questions very thouroughfully to avoid further misunderstandings.

    Will be back later.
    Henk van Velden

  8. #8
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,131

    Default Re: Alias for programs

    Maybe this is the shortest way to a solution.

    Please tell us exactly what you t type in the terminal to start the one version of that program and tell us what yoy want to type instead.

    Please tell us exactly what you type in the terminal to start the other version of that program and tell us what you want to type instead.
    Henk van Velden

  9. #9
    Join Date
    Oct 2014
    Location
    Switzerland
    Posts
    411

    Default Re: Alias for programs

    in my .bashrc I have these lines dedicated for ROOT.
    From people who built it I am instructed to use to load thisroot.sh

    Code:
    source ~/ROOT/thisroot.sh
    but later I learned to change the system path for ROOT.

    Code:
    #Loading Root thisroot.sh in /HOME/ROOT/bin/thisroot.sh
    export ROOTSYS=$HOME/ROOT/
    export PATH=$ROOTSYS/bin:$PATH
    export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PAT
    currently in order to launch ROOT5.34, with this .bashrc I only need to type

    Code:
    root
    but if I want to launch ROOT 6.02. I type
    Code:
    source ~/ROOT6/thisroot.sh
    root

  10. #10
    Join Date
    Oct 2014
    Location
    Switzerland
    Posts
    411

    Default Re: Alias for programs

    sorry
    Code:
    /thisroot.sh
    should be
    Code:
    ~/ROOT/bin/thisroot.sh
    and
    Code:
    ~/ROOT6/bin/thisroot.sh

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •