Coder Social home page Coder Social logo

itomate's Introduction

iTomate

Automate your iTerm layouts and session setup

Define your iTerm layouts, commands to execute in the form of yaml files and run a single command to have iTerm prepare itself for you to start working.

Requirements

  • iTerm2 Version 3.3 or later
  • Python 3.5 or later

Installation

Make sure that you are running Python 3.5 or later

pip install itomate

Enable Python API usage in iTerm preferences.

itomate --version

Example

The layout, number of panes, tabs, titles and commands is configurable and is detailed below.

Usage

Open iTerm and simply run the below command

itomate -c config.yml

If you don't provide -c flag, itomate will look for itomate.yml file in the current directory and use that.

Here is the list of options available

itomate [-c,--config <config-file>] # Sets up the iTerm session
        [-h,--help]                 # Shows the help screen
        [-v,--version]              # Shows the installed itomate version
        [-n,--new]                  # Runs itomate in a new window

Configuration

Configuration file to set up the sessions has the format below

version: "1.0"
profile: "My Profile"
tabs:
  window-1:
    root: "~/Documents/Projects/my_project"
    title: "Window 1"
    panes:
      - title: "Some Pane Title"
        position: "1/1"
        commands:
         - !ENV "db authenticate ${DB_PASSWORD}"
         - "second command"
        prompt: "populated command"
      - position: "1/2"
        focus: true
        badge: "Jobs"
      - position: "2/1"
      - position: "2/2"
  window-2:
    title: "Window 2"
    panes:
      - position: "1/1"
      - position: "1/2"
      - position: "2/1"

Details for each of the configuration objects above is given below

Key Description
version Refers to the itomate configuration version. Should always be 1.
profile Name of the profile you would like to use for all panes. If using -n argument to launch a new window, then window specific profile settings will be applied
tabs Windows or tabs in the iTerm window.
window-1 Replace with the unique project id e.g. web-catalog-pim
root Root path for all panes within a tab
title Title to be shown in the title bar of the current tab
badge Set the Badge Text of the pane
position Position of the pane in the window. It has the format of number1/number2 where number1 refers to the column and number2 refers to the row in the column. More on this later in the readme. position is the only required key in a pane
focus Pane to be in focus when itomate is finished. focus: true. There should only be one focus flag per Tab. If multiple are found, it will focus on the last pane evaluated.
commands List of commands to execute in the current pane.
prompt A command which will remain populated in the prompt after all commands have finished executing. The prompt command itself is not executed automatically.

Environment Variables

Operating System Environment Variables can be used to create templates with secrets and variables. This allows itomate files to be safely committed to version control. Note in the above configuration example the line using the environment variable is prefixed with the !ENV tag and then uses one or more Environment Variables wrapped in the ${ } syntax.

Layouts

The parameter position in each pane decides where each of the window panes will be displayed. The position value has the format below

x / y – both x and y are required parameters

x: refers to the column in the window
y: refers to the row of the given column x

Here are some of the examples for different pane layouts

Single Pane Window

For single pane, since there is one column and one row, the position for pane would be 1/1

.------------------.
| 1/1              |
|                  |
|                  |
|                  |
|                  |
|                  |
|                  |
|                  |
|                  |
'------------------'

Here is how the configuration would look like

version: "1.0"
tabs:
  some-project:
    title: "Some Project"
    panes:
      - title: "Single Pane"
        position: "1/1"
        commands:
          - "cd ~/Workspace/some-project"
          - "git pull origin master"
          - "yarn dev"

Two Panes Vertical Split Layout

For two panes with equal split or in other words two columns with one row in each, the positions would be 1/1 for the pane on the left and 2/1 for the pane on the right i.e. the second column.

.------------------.------------------.
| 1/1              | 2/1              |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |                  |
'------------------'------------------'

Here is how it would look in the configuration

version: "1.0"
tabs:
  some-project:
    root: "~/Workspace/some-project"
    title: "Some Project"
    panes:
      - title: "First Half"
        position: "1/1"    # <-- Notice the position
      - title: "Second Half"
        position: "2/1"    # <-- Notice the position

Two Columns, Three Panes Layout

The layout below now has two columns. First column has only one row so position for that would be 1/1. For the second column we have two panes i.e. two rows; first pane in the second column would be 2/1 and the second one would be 2/2.

.------------------.------------------.
| 1/1              | 2/1              |
|                  |                  |
|                  |                  |
|                  |                  |
|                  |------------------|
|                  | 2/2              |
|                  |                  |
|                  |                  |
|                  |                  |
'------------------'------------------'

Configuration for that would be:

version: "1.0"
tabs:
  some-project:
    root: "~/Workspace/dev-server"
    title: "Some Project"
    panes:
      - position: "1/1"    # <-- Notice the position
      - position: "2/1"    # <-- Notice the position
        commands:
          - "./run"
      - position: "2/2"    # <-- Notice the position
        commands:
          - "git standup"

Note that the commands and title are optional parameters in panes. Only position is required.

Two Columns, Four Panes Layout

.------------------.------------------.
| 1/1              | 2/1              |
|                  |                  |
|                  |                  |
|                  |                  |
|------------------|                  |
| 1/2              |                  |
|                  |                  |
|                  |                  |
|------------------|                  |
| 1/3              |                  |
|                  |                  |
|                  |                  |
'------------------'------------------'

Configuration for that would be:

version: "1.0"
tabs:
  some-project:
    root: "~/Workspace/project"
    title: "Some Project"
    panes:
      - position: "1/1"    # <-- Notice the position
        commands:
          - "Make clean"
      - position: "1/2"    # <-- Notice the position
        commands:
          - "git standup"
      - position: "1/3"    # <-- Notice the position
        commands:
          - "git standup"
      - position: "2/1"    # <-- Notice the position
        commands:
          - "./run"

Three Columns Five Pane Layout

.------------------.------------------.------------------.
| 1/1              | 2/1              | 3/1              |
|                  |                  |                  |
|                  |                  |                  |
|                  |                  |                  |
|                  |------------------|                  |
|                  | 2/2              |                  |
|                  |                  |                  |
|                  |                  |                  |
|                  |------------------|                  |
|                  | 2/3              |                  |
|                  |                  |                  |
|                  |                  |                  |
'------------------'------------------'------------------'

Configuration for that would be

version: "1.0"
tabs:
  some-project:
    title: "Some Project"
    panes:
      - position: "1/1"    # <-- Notice the position
      - position: "2/1"    # <-- Notice the position
      - position: "2/2"    # <-- Notice the position
      - position: "2/3"    # <-- Notice the position
      - position: "3/1"    # <-- Notice the position

Contributors

Special thanks to the contributors for making iTomate possible

Similar Projects

There is itermocil which relies on Applescript that has been deprecated by iTerm, has limited layout options, and is pretty limited in terms of what it can achieve because of AppleScript. iTomate on the other hand uses iTerm's newly introduced Python API, has flexible layouts support and can be extended using iTerm's pretty powerful API.

Contributions

Feel free to submit pull requests, create issues, spread the word.

License

MIT © Kamran Ahmed

itomate's People

Contributors

johnlegrandrichards avatar kamranahmedse avatar psalant726 avatar zachvalenta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

itomate's Issues

[FR] Interactive mode

Sometimes I have no config around, but I want to rename a tab and maybe even set a color. I can fallback to other solutions, there are ways to set a title, however only itomate can do it in a way that the title will not be lost when I start vim, because it uses the python API directly.

I would love to have an interactive mode, so I can quickly name and color the current tab without messing around.

I.e.:

itomate --name "red tab" --color #ff0000
# or 
itomate -n "blue tab" -c blue

Requires broad iTerm API permissions

On iTerm 3.4 all itomate commands seem to fail with the error:

websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 401

if the API permission setting is:
image
But if the permission is switched to "Allow all"
image
then everything works.

[FR] Add Tab Colors

Add ability to define tab colors
This could be RGB or have some predefined colors

example:

version: "1.0"
tabs:
window-1:
root: "~/Documents/Moxy-Projects/navblue-service"
color: [255, 128, 128]
title: "My Title"
panes:
- title: "A pane titler"
position: "1/1"

[FR] Highlight selected pane, not the last one

Hi, great idea with the lib! However, I have two notes (the second one in another issue).

The first one is the option to select which pane should be highlighted after creation. Now, when I have 3 panes: 1/1, 2/1, 2/2, the one always highlighted is 2/2. I'd like to be able to choose e.g. 1/1 as the default one.

Feature request: configure the size of the iTerm window

Hi !

First of all, thank you ! I've been looking for this kind of automation tool for iTerm2 for looong time!

I was wondering, it might be possible to define the size of the window at launch.

2 parameters here:

  • original / latest screen resolution OR full screen at launch
  • "native full screen windows" activated or not (Preferences> General> Window)

I don't know if this is something that can be simply configured.

commands not executed within python3.8

I just upgraded the python version from 3.7 to 3.8.
Now the commands defined on the .yml aren't launched. Instead of that, they're printed without being executed.

It was working correctly with the 3.7 but not within the 3.8

[FR] Create as a new window

Hi, this issue is about a possibility to set up iTerm window with itomate as a new one, not in the place of the current one.

[FR] Select iTerm profile for a new window

Currently using itomate with -n option to create a new window would use a default iTerm profile. It would be valuable to be able to select a custom profile, e.g. with different shell or window size.

[FR] Add ability to define Status Bar Components

The new Status bar is really awesome. It would be nicd to be able to define what your status bar was comprised of. There would be one status bar for your iterm2 window.

version: "1.0"
status-bar: 
  - Battery-Level
  - User-Name
  - Empty-Space
  - Search-Tool
tabs:
  window-1:
    panes:
        position: "1/1"

[FR] Set Badge Text For Each Pane

Let's make it so you can predefine badges on each pane. These badges make it really easy to see what pane launched as what even if all text is cleared

All commands throwing an error

When I issue any of the commands available (-c, -h or -n) (but not -v) I am getting the following exception and I'm not really sure where the error is stemming from:

myusernamehere@myusernamehere-ltm Downloads % itomate --help
usage: itomate [-h] [-c CONFIG] [-v] [-n]

Workflow automation and layouts for iTerm

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        Path to the configuration file
  -v, --version         Show version
  -n, --new             Run in new window

For details on creating configuration files, please head to:

https://github.com/kamranahmedse/itomate
Traceback (most recent call last):
  File "/Users/myusernamehere/.pyenv/versions/3.7.0/lib/python3.7/site-packages/websockets/protocol.py", line 827, in transfer_data
    message = await self.read_message()
  File "/Users/myusernamehere/.pyenv/versions/3.7.0/lib/python3.7/site-packages/websockets/protocol.py", line 895, in read_message
    frame = await self.read_data_frame(max_size=self.max_size)
  File "/Users/myusernamehere/.pyenv/versions/3.7.0/lib/python3.7/site-packages/websockets/protocol.py", line 971, in read_data_frame
    frame = await self.read_frame(max_size)
  File "/Users/myusernamehere/.pyenv/versions/3.7.0/lib/python3.7/site-packages/websockets/protocol.py", line 1051, in read_frame
    extensions=self.extensions,
  File "/Users/myusernamehere/.pyenv/versions/3.7.0/lib/python3.7/site-packages/websockets/framing.py", line 105, in read
    data = await reader(2)
  File "/Users/myusernamehere/.pyenv/versions/3.7.0/lib/python3.7/asyncio/streams.py", line 677, in readexactly
    raise IncompleteReadError(incomplete, n)
asyncio.streams.IncompleteReadError: 0 bytes read on a total of 2 expected bytes

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/myusernamehere/.pyenv/versions/3.7.0/lib/python3.7/site-packages/iterm2/connection.py", line 173, in _async_dispatch_forever
    data = await self.websocket.recv()
  File "/Users/myusernamehere/.pyenv/versions/3.7.0/lib/python3.7/site-packages/websockets/protocol.py", line 509, in recv
    await self.ensure_open()
  File "/Users/myusernamehere/.pyenv/versions/3.7.0/lib/python3.7/site-packages/websockets/protocol.py", line 803, in ensure_open
    raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: code = 1006 (connection closed abnormally [internal]), no reason

Any suggestions? I do have and use PyEnv on my laptop, could that have anything to do with it?

how can i use tmux

commands:
- "tmux"
- "python manage.py runserver_plus 9000"
- "tmux detach"

it didn't work

Creating panes under a single broad pane does not work.

Maybe I'm not going about this the right way, but I've been playing around with this a bit and I can't seem to make it work. Based off of the documented position scheme, I "should" be able to create a row of panes below a single larger one.

Below is the documented example of the small panes arranged vertically next to a full height pane with their corresponding positions:

.--------------------.--------------------.
| 1/1                | 2/1                |
|                    |                    |
|                    |                    |
|                    |                    |
|--------------------|                    |
| 1/2                |                    |
|                    |                    |
|                    |                    |
|                    |                    |
|--------------------|                    |
| 1/3                |                    |
|                    |                    |
|                    |                    |
|                    |                    |
'--------------------'--------------------'

Following that logic I had hoped the following would work but it doesn't see to. It only creates the first pane on the second row and then stops:

.-----------------------------------------.
| 1/1                                     |
|                                         |
|                                         |
|                                         |
|                                         |
|                                         |
|-------------.-------------.-------------.
| 1/2         | 2/2         | 3/2         |
|             |             |             |
|             |             |             |
|             |             |             |
|             |             |             |
|             |             |             |
'-------------'-------------'-------------'

Do I have the positions wrong, or is this a limitation in the program?

[FR] Allow 1/1 + 1/2 + 2/2 combination

Hi, another issue from my side.

When I want to create panes in such a combination: 1/1 + 1/2 + 2/2, which graphically looks like:

|      pane 1     |
| pane 2 | pane 3 |

as a final result I get only 1/1 and 1/2 panes, so:

|      pane 1     |
|      pane 2     |

The last pane is just missing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.