Executing program through Terminal

bashcommand linepythonterminal

I have Sage (math program) and I want to execute it through terminal.

I know I can go to the directory and execute it with –

open Sage.app

But would I really want to do is simply type sage in terminal and have it run. I believe this is a fairly simple task, but I just don't have any idea! Thanks.

Best Answer

You need an alias. Typing alias sage='open /PATH/TO/Sage.app' will create an alias which will do exactly what you want, run the program just by typing sage. The problem is that this will only last until you close that terminal window (bash). So, you need to create that alias each time you run a new bash. To do so, just:

  1. Create or modify a text file called .bash_profile in your home directory.
  2. Add alias sage='open /PATH/TO/Sage.app' on it
  3. Save the file
  4. Load the file once by typing . ~/.bash_profile

Remember that it will be case sensitive, so if you type Sage (instead of sage) it won't work.