Automate your iTerm layouts and session setup

栏目: IT技术 · 发布时间: 4年前

内容简介:Define your iTerm layouts, commands to execute in the form of yaml files and run a single command to have iTerm prepare it self for you to start working.Make sure that you are running Python 3.5 or later

iTomate

Automate your iTerm layouts and session setup

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 it self 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.

Automate your iTerm layouts and session setup

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

Configuration

Configuration file to set up the sessions has the format below

version: "1.0"
tabs:
  window-1:
    title: "Window 1"
    panes:
      - title: "Some Pane Title"
        position: "1/1"
        commands:
         - "some command"
         - "second command"
      - position: "1/2"
      - 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.
tabs Windows or tabs in the iTerm window.
window-1 Replace with the unique project id e.g. web-catalog-pim
title Title to be shown in the title bar of the current tab
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
commands List of commands to execute in the current pane.

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:
    title: "Some Project"
    panes:
      - title: "First Half"
        position: "1/1"    # <-- Notice the position
        commands:
          - "cd ~/Workspace/some-project"
      - title: "Second Half"
        position: "2/1"    # <-- Notice the position
        commands:
          - "cd ~/Workspace/another-project"

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:
    title: "Some Project"
    panes:
      - position: "1/1"    # <-- Notice the position
      - position: "2/1"    # <-- Notice the position
        commands:
          - "cd ~/Workspace/dev-server"
          - "./run"
      - position: "2/2"    # <-- Notice the position
        commands:
          - "cd ~/Workspace/project"
          - "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:
    title: "Some Project"
    panes:
      - position: "1/1"    # <-- Notice the position
        commands:
          - "cd ~/Workspace/project"
          - "Make clean"
      - position: "1/2"    # <-- Notice the position
        commands:
          - "cd ~/Workspace/project"
          - "git standup"
      - position: "1/3"    # <-- Notice the position
        commands:
          - "cd ~/Workspace/project"
          - "git standup"
      - position: "2/1"    # <-- Notice the position
        commands:
          - "cd ~/Workspace/dev-server"
          - "./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


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

社会再平衡

社会再平衡

[加] 亨利·明茨伯格 / 陆维东、鲁强 / 东方出版社 / 2015-9 / 38.00元

明茨伯格曾坦言:我虽然不是律师,但我觉得有必要质疑法律的失效;我也不算是经济学家,但我觉得有义务来挑战一切事物以经济为指标的标准;我也不是人类学家、社会学家、心理学家,或者政治科学,更不是活动分子,但是在我的讨论中,文化、行为、权力、社会运动都扮演了重要的角色。我是一个合成者,我最成功的书都囊括了不同来源的想法。 明茨伯格创作《社会再平衡》这本书的初衷是因为关注身边的趋势:环境的恶化、民主的......一起来看看 《社会再平衡》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具