An open API service indexing awesome lists of open source software.

https://github.com/luciopaiva/itermoxyl

Tool to automatically open multiple ssh connections in iTerm2 by querying ~/.ssh/config.
https://github.com/luciopaiva/itermoxyl

iterm2 itermocil ssh ssh-config teamocil

Last synced: 7 months ago
JSON representation

Tool to automatically open multiple ssh connections in iTerm2 by querying ~/.ssh/config.

Awesome Lists containing this project

README

          

![iTermoxyl](banner.png)

# iTermoxyl

iTermoxyl is command line tool to automatically open multiple ssh connections in [iTerm2](https://iterm2.com/) by directly querying `~/.ssh/config` using patterns provided via the command line.

![example](example.gif)

It is a slightly different medicine for a slightly different problem. iTermoxyl was inspired by [itermocil](https://github.com/TomAnthony/itermocil), which was inspired by [teamocil](https://github.com/remiprev/teamocil).

iTermoxyl is designed to be simple to use, with minimal interaction needed to get it running. Once ssh connections are established, use iTerm2's broadcast input feature to send commands to all machines at once (`Shell -> Broadcast input` or simply `cmd + shift + i`).

Features:

- magically learns about existing hosts by reading from `~/.ssh/config`
- doesn't require any configuration files (tools like `itermocil` and `i2cssh` require you to manually create YAML descriptions of your environments)
- smart pattern matching: no need to type in the name of each machine you want to connect to
- supports [ssh config Include directives](https://man.openbsd.org/ssh_config#Include)
- supports loose matches (see below)

## How to install

`cd` to the destination directory and:

curl -O https://raw.githubusercontent.com/luciopaiva/itermoxyl/master/itermoxyl
chmod u+x itermoxyl

Make sure to add it to the path so it can be called anywhere.

You need to have iTerm2 installed (obviously), but nothing else. The script is written in Python 2.7 and your macOS already comes with it.

## How to use

Consider the following sample `~/.ssh/config` file:

```
Host foo-1
HostName 10.0.0.1
Host foo-2
HostName 10.0.0.2
Host foo-3
HostName 10.0.0.3
Host foo-4
HostName 10.0.0.4
Host foo-5
HostName 10.0.0.5

Host bar-1
HostName 10.0.1.1
Host bar-2
HostName 10.0.1.2

Host server-1-a
HostName 192.168.0.1
Host server-1-b
HostName 192.168.0.2
Host server-2-a
HostName 192.168.1.1
Host server-2-b
HostName 192.168.1.2
```

Let's try a few combinations. To open:

1. all `foo` machines:

itermoxyl foo

2. `foo-2` and `bar-2`:

itermoxyl foo,bar 2

3. `server-1-a` and `server-2-a`:

itermoxyl server a

4. `foo-1`, `foo-2`, `foo-3`:

itermoxyl foo 1-3

5. `foo-1`, `foo-3`, `foo-4`, `foo-5`:

itermoxyl foo 1,3-5

### The underlying pattern-matching algorithm

The general rule is:

itermoxyl TERM_0 TERM_1 ... TERM_N

Terms will be joined into the following regular expression:

(?:TERM_0).*?(?:TERM_1).*?(?:TERM_N)

Which acts as a kind of a loose search. Moreover, each term is treated as a potential comma-separated list of names:

TERM => NAME_0,NAME_1,...,NAME_N

Which will get converted to the following regular expression:

(?:NAME_0|NAME_1|NAME_N)

This allows for matches like the `foo,bar` in the example above.

Finally, the last term in a list with more than one term is treated differently. If its name parts are actually numbers, they will exceptionally be translated into the following regular expression:

(?