Terminal Applications: Starting from CLI

Posted:
in macOS edited January 2014
Hey folks -



I'm slowly but surely converting to the OS X world from Linux/UNIX/X11/etc. I'm running into a couple of interesting roadblocks that I'm hoping folks can help me with.



With my X11 window manager of choice, I have menu items set up to run certain scripts. One script will open a terminal application for the local machine. One will open a term and sudo to root for me. Several will open a term and ssh off to other hosts that I need to log in to during work, etc.



I'm reasonably confident I can accomplish this with xterm. But I don't think I can with the Terminal application, or other apps I've tried (like iterm, etc.) Once they're running from the CLI, they won't start *another* window. Nor do I know how to feed them arguments like "hey, ssh to host x.y.z.a".



Anyone have any suggestions? I can just use xterm, but I'd rather use something a bit newer.



Thanks!



jas

Comments

  • Reply 1 of 2
    pyr3pyr3 Posts: 946member
    Termainl.app (and I believe iTerm.app) will open .term files. A .term file is just a plist (XML property list). Most of the stuff defined in the property list will be things like windows size, color, transparency, and other preferences. But one of the properties allows you to define a command to be run as soon as the window is open. So... you can just create a bunch of .term files for the types of terminals you want to open. Then running 'open -a Terminal.app my-term-file.term' from CLI or shell script will use LaunchServices (I believe) to open the document. If Terminal.app gets a request to open a .term file it will open a new window even if it is already running. You can do a google search (or search macosxhints.com) to find the PLIST element and the other .term elements.



    There is also a folder in ~/Library/ (~/Library/Terminal/, I think) that allows you to put all your .term files into it. They will then appear on a drop-down option under the 'File' menu of Terminal.app. iTerm.app similarly allows you to define terminals that will auto-run a command (like ssh, telnet, etc) and they appear on a drop-down menu (I think it's also under the File menu).
  • Reply 2 of 2
    Quote:

    Originally posted by pyr3

    Termainl.app (and I believe iTerm.app) will open .term files. A .term file is just a plist (XML property list).



    Cool, thank you much for the response. Someone else also suggested using an Applescript to accomplish the same thing. Between these two suggestions, I should be able to figure something out.



    Thanks!



    jas
Sign In or Register to comment.