# Smug - tmux session manager
Inspired by [tmuxinator ](https://github.com/tmuxinator/tmuxinator ) and [tmuxp ](https://github.com/tmux-python/tmuxp ).
Smug automates your [tmux ](https://github.com/tmux/tmux ) workflow. You can create a single configuration file, and Smug will create all the required windows and panes from it.
![gif ](https://raw.githubusercontent.com/ivaaaan/gifs/master/smug.gif )
The configuration used in this GIF can be found [here ](#example-2 ).
## Installation
### Download from the releases page
Download the latest version of Smug from the [releases page ](https://github.com/ivaaaan/smug/releases ) and then run:
```bash
mkdir smug & & tar -xzf smug_0.1.0_Darwin_x86_64.tar.gz -C ./smug & & sudo mv smug/smug /usr/local/bin & & rm -rf smug
```
Don't forget to replace `smug_0.1.0_Darwin_x86_64.tar.gz` with the archive that you've downloaded.
### Git
#### Prerequisite Tools
* [Git ](https://git-scm.com/ )
* [Go (we test it with the last 2 major versions) ](https://golang.org/dl/ )
#### Fetch from GitHub
The easiest way is to clone Smug from GitHub and install it using `go-cli` :
```bash
cd /tmp
git clone https://github.com/ivaaaan/smug.git
cd smug
go install
```
## Usage
```
smug < command > [< project > ] [-f, --file < file > ] [-w, --windows < window > ]... [-a, --attach] [-d, --debug]
```
### Options:
```
-f, --file A custom path to a config file
-w, --windows List of windows to start. If session exists, those windows will be attached to current session.
-a, --attach Force switch client for a session
-d, --debug Print all commands to ~/.config/smug/smug.log
```
### Examples:
```
$ smug start blog
$ smug start blog:win1
$ smug start blog -w win1
$ smug start blog:win1,win2
$ smug stop blog
$ smug start blog --attach
$ smug start -f ./project.yml -w win1 -w win2
$ smug stop -f ./project.yml -w win1
```
### Examples
To start/stop a project and all windows, run:
```console
xyz@localhost:~$ smug start project
xyz@localhost:~$ smug stop project
```
When you already have a running session, and you want only to create some windows from the configuration file, you can do something like this:
```console
xyz@localhost:~$ smug start project:window1
xyz@localhost:~$ smug start project:window1,window2
xyz@localhost:~$ smug start project -w window1
xyz@localhost:~$ smug start project -w window1 -w window2
xyz@localhost:~$ smug stop project:window1
xyz@localhost:~$ smug stop project -w window1 -w window2
```
## Configuration
Configuration files stored in the `~/.config/smug` directory in the `YAML` format, e.g `~/.config/smug/your_project.yml` .
### Examples
#### Example 1
```yaml
session: blog
root: ~/Developer/blog
before_start:
- docker-compose -f my-microservices/docker-compose.yml up -d # my-microservices/docker-compose.yml is a relative to `root`
stop:
- docker stop $(docker ps -q)
windows:
- name: code
root: blog # a relative path to root
manual: true # you can start this window only manually, using the -w arg
layout: main-vertical
commands:
- docker-compose start
panes:
- type: horizontal
root: .
commands:
- docker-compose exec php /bin/sh
- clear
- name: infrastructure
root: ~/Developer/blog/my-microservices
layout: tiled
panes:
- type: horizontal
root: .
commands:
- docker-compose up -d
- docker-compose exec php /bin/sh
- clear
```
#### Example 2
```yaml
session: blog
root: ~/Code/blog
before_start:
- docker-compose up -d
stop:
- docker-compose stop
windows:
- name: code
layout: main-horizontal
commands:
- $EDITOR app/dependencies.php
panes:
- type: horizontal
commands:
- make run-tests
- name: ssh
commands:
- ssh -i ~/keys/blog.pem ubuntu@127.0.0.1
```