Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I am new to Mac OS (I am currently using Mavericks) and I have performed google searches as well as search on StackExchange regarding my question but the discussions I came across don't quite answer my question.

I come from the linux world and it is trivial for me to set a custom command in the gnome-panel and then put in any argument I like; many of these commands invoke xterm.

So for example, suppose I want to create a launcher to connect to a remote server with lot of arguments as below.

xterm -fg orange -bg black -e ssh me@myserver

I cam across a post that suggested I use the automator. I am however unable to do this successfully.

So far in the automator, I have

open -a "/opt/X11/bin/xterm" --args "-fg orange -bg black -e ssh me@myserver"

however this command does not execute properly and I am not sure how to solve this problem.

Thanks Les p.s. Note that if I launch the Terminal and type in xterm, it launches as expected

share|improve this question
    
Why not use the built in terminal? It's really highly customizable, and you can make it emulate x-term. Terminal brings a lot of advantages like full screen mode, copy/paste with + c and + v. It also let's you build your own custom profiles, allowing for custom fonts, transparency, and even default commands ran on start (such as to start an SSH session). –  XAleXOwnZX Dec 27 '13 at 16:59

2 Answers 2

up vote 2 down vote accepted

You can write it as a shell script within the Rune Shell Script action:

enter image description here

I tried this and it worked as expected.

share|improve this answer
    
This is exactly what I was looking for. Thank you –  Lee Sande Dec 27 '13 at 14:54
1  
Any idea how I can change the icon for this executable? –  Lee Sande Dec 27 '13 at 15:09
    
You can change the icon of pretty much any volume/folder/file by pressing + i, and pasting any image file into the image well in the top left corner –  XAleXOwnZX Dec 27 '13 at 16:59
    
Thank you for the response. I did apple + i and then I drag and dropped the image (a png file); however the icon changes to a generic "PNG" file mime type icon not the actual image. Do I need to have a specific file format for icons? I also followd the steps here (365icon.com/icon-styles/dock-icons/how-to-change-mac-dock-icons) but even after pasting the new image (after selecting the icon on the upper left), the new image does not show up (after restart of the program). –  Lee Sande Dec 27 '13 at 18:57
1  
I can't rate up because I don't have sufficient reputation to do so. Sorry. –  Lee Sande Dec 29 '13 at 1:31

Automator and AppleScript are the best ways at creating custom scripts/apps that perform commands as you described. Each have their pros and cons. For most tasks I prefer to write AppleScripts, probably because I'm a programmer myself and because they are easy to access and edit.

To write AppleScripts, you can use the OS X provided program called "AppleScript Editor." AppleScript editor allows you to write your AppleScripts and save them as an actual AppleScript with a file extension of .scpt or as an Application (.app) which can be run from anywhere.

If you save your AppleScript in the AppleScript format (.scpt), and with the help of a application called FastScripts (also available in the Mac App Store), all your personal scripts and system scripts can be made easily accessible in the menubar. And Fast Scripts provides the extra benefit of allowing you to assign keyboard shortcuts to them. You can do the same with Automator workflows, I just find it's easier to do with AppleScripts and FastScripts.

Here is a sample AppleScript I created that I have previously shared on the boards that toggles the visibility of hidden files in OS X. This is one of my more basic scripts which is I why I am showing it as an example of how simple it is to write an AppleScript. With the help of FastScripts, I set a keyboard shortcut of ^ + + + . to activate this script.

tell application "System Events"

    set hiddenFilesDisplayStatus to do shell script "defaults read com.apple.finder AppleShowAllFiles"
    set hiddenFilesNewDisplayStatus to "NO"

    if hiddenFilesDisplayStatus is "NO" then
        set hiddenFilesNewDisplayStatus to "YES"
    end if

    do shell script "defaults write com.apple.finder AppleShowAllFiles " & hiddenFilesNewDisplayStatus
    do shell script "killall Finder"

end tell

I have a variety of other AppleScripts that perform various tasks, so if I were you, look at AppleScripts first, then look at using Automator. There are many resources out there for helping you create AppleScripts, and you'll find that there are many others that have already written AppleScripts that may already do what you are looking for.

To answer your specific use case

Try creating an AppleScript with the following command, notice the fully qualified path to xterm. On my machine it was different than yours. It's important to note that I have XQuartz installed on my machine since Mavericks does not come shipped with X11 any longer.

do shell script "/usr/X11/bin/xterm -fg orange -bg black -e ssh me@myserver"

I tried the above command, pointed to my server and it worked fine. What would be really cool if you got this working with this AppleScript is that you could even set up the AppleScript to ask for input for the username and server you with to connect to, and it'll set that in the shell script command for you and if nothing is provided, you could have it default to a particular username/server. :)

FYI, I figured out the pathing issue to xterm using this SO article: http://stackoverflow.com/questions/11206872/open-xterm-telnet-connection-mac-os-x

share|improve this answer
    
Thank you for your answer and the link to the path problem in xterm. –  Lee Sande Dec 27 '13 at 14:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.