pallavJha / chaakoo

Slice and dice your TMUX windows and panes
Apache License 2.0
82 stars 2 forks source link
golang tmux

chaakoo

Test

  1. Introduction
  2. Configuration
  3. Using Chaakoo
  4. Examples
  5. Download
  6. License

Introduction

Chaakoo is a wrapper over TMUX that can create sessions, windows and panes from a grid based layout. The idea here is inspired by the CSS grid template areas.

For example, this grid:

vim  vim  vim  term
vim  vim  vim  term
play play play play

will create the following layout:

window1

The layout can be a little complex too based on the further pane divisions, like,

arandr  arandr  bzip    cat
vim     vim     err     cat
vim     vim     file    file
grafana grafana grafana grafana
grafana grafana grafana grafana

window2

Configuration

A configuration yaml for one window with 3 panes, like, the first example, is here:

name: code-environment
windows:
  - grid: |
      vim  vim  vim  term
      vim  vim  vim  term
      play play play play
    name: window1
    commands:
      - pane: vim
        command: |
          vim
      - pane: term
        command: |
          cd ~
          systemctl status
        workdir: /home/waterbottle/code
      - pane: play
        command: |
          tail -f /var/log/messages

Note: The commands section or commands for a pane are not a required field. Chaakoo can just be used to create the pane layout and then the user can take over and execute their commands.

Using Chaakoo

# Start a TMUX server
$ tmux start-server

# and then pass the config to Chaakoo
$ chaakoo -c examples/1/chaakoo.yaml 
4:43PM ERR github.com/pallavJha/chaakoo/tmux_wrapper.go:349 > unable to get the list of the present sessions error="exit status 1" sessionName=code-environment stderr="no server running on /tmp/tmux-1000/default\n" stdout=
4:43PM INF github.com/pallavJha/chaakoo/cmd/chaakoo.go:66 > session created successfully, it can be attached by executing:
4:43PM INF github.com/pallavJha/chaakoo/cmd/chaakoo.go:67 > tmux a -t code-environment

# Attach the TMUX session
$ tmux a -t code-environment

Usage: chaakoo [flags]

Flags: -c, --config string config file (default is ./chaakoo.yaml) -d, --dry-run if true then commands will only be shown and not executed -e, --exit-on-error if true then chaakoo will exit after it encounters the first error during command execution -r, --height int terminal dimension for rows or height, if 0 then rows and cols will be found internally -h, --help help for chaakoo -v, --verbose enable verbose logging -V, --version print the version -w, --width int terminal dimension for cols or width


## Examples
There are more examples present in the [examples](./examples/2) directory with configurations and snapshots.

## Download
The latest binary can be downloaded from the [latest GitHub release](https://github.com/pallavJha/chaakoo/releases/latest).
The binaries are statically linked.

Or 

```bash
$ go install github.com/pallavJha/chaakoo/cmd/chaakoo@v0.0.5

License

Copyright 2021 Pallav Jha

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.