How can I automatically start two SSH sessions in two Terminal tabs?

883

Solution 1

Open /Applications/Utilities/AppleScript Editor.app and enter the following:

tell application "Terminal"
    activate
    tell application "System Events"
        keystroke "t" using command down # new tab
        keystroke "ssh myserver"
        key code 36 # press enter
        keystroke "t" using command down # new tab
        keystroke "ssh myserver2"
        key code 36 # press enter
    end tell
end tell

Save as script or application. Anytime you execute, Terminal will be brought to front (started if necessary), and two new tabs will be created for your SSH sessions.

In this answer I outlined how to check whether a window is already open (without an application running) to prevent opening one tab/window too many.

Solution 2

You can create a Window Group to make it convenient to recreate windows and tabs, and you can use Settings profiles to issue ssh commands when windows/tabs are created.

  1. Duplicate or create two new profiles (Terminal > Preferences > Settings).
  2. In each profile, go to Shell and enable "Run command". Fill in the appropriate ssh commands for each profile.
  3. Create a new window with one of the profiles (Shell > New Window > [the first ssh profile]).
  4. Create a new tab with the other profile (Shell > New Tab > [the second ssh profile]).
  5. Create a window group for the window (Window > Save Windows as Group). Be sure you have no other terminal windows open at the time, otherwise they will all be saved in the group.

Now, whenever you want to recreate that window and start the ssh sessions, choose Window > Open Window Group > [your group].

You can also tell Terminal to open the window group every time you start Terminal (Terminal > Preferences > Startup > On startup, open: > Window group:).

Share:
883

Related videos on Youtube

Alex
Author by

Alex

Updated on September 17, 2022

Comments

  • Alex
    Alex almost 2 years

    We are taking a long time on first runs of our linq to EF queries. I was surprised to see no difference after pre-generating views. I ran across the following claim on stackoverflow

    View generation only helps for "standard" queries (e.g., when you call someObject.RelatedEnd.Load() or MyContext.SomeSetName(). It doesn't help for ad hoc queries with LINQ or ESQL, for obvious reasons. Use CompiledQuery to optimize those.

    When he says "for obvious reasons" I have to say, "Well,not obvious to me yet". If I understand this correctly he is claiming Linq to SQL queries are not affected by pregenerating EF views.

    I had thought entity views were generic mappings between entities and tables, and bore no relation to any specific query. Is this mistaken?

    I can see huge amounts of time being used in the first run of our Linq to Entities queries, with dramatically smaller times thereafter, so I assumed views were being generated for the relevant entities and tables. If it isn't an EF view that can be pregenerated taking all that first run time, then what is it?

    So my question has three parts:

    1. Are EF views generated for each query, or do they just relate tables to entities regardless of the queries made?

    2. Is the above claim that pregenerating EF views makes no difference in Linq to EF queries correct? Does one have to use CompileQueries instead?

    3. What are the "obvious reasons" referred to above?

    Note: I wouldn't even ask but there are quite a few recommendations on the internet (including msdn) to pregenerate views if you are using EF. This is the only place I have seen it suggested that if you use Linq to Entities then pregenerating is irrelevant to your queries.

  • SamJolly
    SamJolly over 9 years
    This is very topical for me since I use TPH inheritance for a child class that is made up of complex type properties. Pregenerated Views of the child class makes no effect on the initial load time which can be 40secs. Successive loads take .5 sec. I am using EF5. Yes I am thinking of upgrading to EF6, but I am worried about the fact that the EF6 runtime now, itself, requires Jitting on first run.