10-26-2009, 06:39 AM #1Help with the bash...alias/script...?
I'm new to Mac OS, just switched from Ubuntu and sometimes its quite hard to get used to different stuff...
So, I searched the Internet for over an hour, but nothing could solve my problem. You will see it is quite simple (at least it was in ubuntu)
All I want to do is following:
To launch a particular program, I have to start X11 (xgterm), change directory and execute a command.
so basically its:
xgterm -sb -geometry 80x24 -title "Image Reduction and Analysis Facility (IRAF)" -bg "black" -fg "orange" -bd "white" -cr "grey" -e "ecl"
and I don't want to type this every time I have to use the program. My question is: Can I create an alias, or write a script, so that I just have to type one simple command to execute those above in the bash?
Another thing is: In ubuntu I could launch all apps by typing their names (whatever was in /usr/local/bin). How do I create such a file, which enables me to launch a specific app from the terminal...?
I hope you can help me
10-26-2009, 11:31 AM #2
- Member Since
- May 03, 2009
- MBP 2.33 4GB: MacPro 8 Core 2.8, 16GB: MacMini 2.26 4GB: MacMin 2.53 4GB: iPhone3GS 32GB
The concepts are the same on OSX so there should not be any real differences in what you are trying to do.
There is obviously no xgterm in OSX, it is simply xterm. Did you install X11 on your Mac? You didn't state the version of OSX you are using.In 10.6 (Snow Leopard) you would have the option to install this during installation. In 10.5 X11 will be on your install disks.
From what I am reading it sounds like you need to update your path to include the directories you want so you can simply type the name in the terminal. You can do this in either a .bash_login or .bashrc file. Example:
Note, there are no '' characters around the dollar sign, these were added for escaping.
My question is: Can I create an alias, or write a script, so that I just have to type one simple command to execute those above in the bash?
10-26-2009, 01:32 PM #3
- Member Since
- Dec 13, 2007
- United States of America
- 2.1GHz MacBook with 4GB RAM, Mac OS X 10.6, iLife and iWork ‘09
For your first question, all you'd need to do is add those commands to a script and then add it to a directory in your PATH to run them with a single command. [Edit: I forgot to mention that you'll probably have to chmod +x the script to run it directly.] In addition, if you want to run the script by opening it from the Finder or even from the Dock, write it as you would a .sh file and then save it as a .command file. If it isn't already, associate it with Terminal.app and then you can simply open it in the Finder or from the Dock to run the script. You can change whether the Terminal window stays open after it finished in the Shell tab of the Settings pane of Terminal's preferences.
As for your second question, just use the open command. For example, open -a Mail will open Mail.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
By scar1 in forum OS X - Operating SystemReplies: 2Last Post: 03-19-2015, 10:49 PM
By Bwoe in forum OS X - Development and DarwinReplies: 5Last Post: 03-23-2011, 09:58 PM
By gilc in forum OS X - Development and DarwinReplies: 5Last Post: 02-25-2010, 05:23 PM
By mac57 in forum OS X - Development and DarwinReplies: 7Last Post: 06-08-2006, 04:01 PM
By ftjogoh in forum Apple NotebooksReplies: 1Last Post: 11-04-2004, 02:14 PM