You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Go to file
spike 80205349b5 set a custom timeout before executing send-keys for commands
In some situations send-keys might fire before the shell prompt
  finished initilization. It happened for me when using fish shell and
  *oh-my-fish* which makes the send-keys start executing bofore my shell
  is ready and I endup with a written command that is not executed

  This patch adds a custom `sendkeys_timeout` as a top level option that
  takes an integer in milliseconds. It will ensure a Sleep call is made
  before.
2 years ago
.github chore: Remove goreleaser.yml 2 years ago
completion Update bash completions (#65) 3 years ago
man/man1 Make documentation complete (#53) 3 years ago
.gitignore Add new flag `-i` that allows to create new windows inside current session 2 years ago
.goreleaser.yml Fix goreleaser 3 years ago
.smug.yml feat: Use .smug.yml as a default configuration file 2 years ago
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 3 years ago
LICENSE Create LICENSE 3 years ago
Makefile [enhancement] Pass version via ldflags, trim GOPATH in stacktraces (#50) 3 years ago
README.md feat: Use .smug.yml as a default configuration file 2 years ago
commander.go fix: Check if project is also empty before using an environment variable 2 years ago
commander_test.go Increase test coverage (#19) 3 years ago
config.go set a custom timeout before executing send-keys for commands 2 years ago
config_test.go set a custom timeout before executing send-keys for commands 2 years ago
context.go Create a default window, and then kill it, instead of using (#23) 3 years ago
context_test.go Add context_test.go 3 years ago
go.mod Replace docopt (#20) 3 years ago
go.sum Replace docopt (#20) 3 years ago
main.go feat: Use .smug.yml as a default configuration file 2 years ago
options.go fix: Check if project is also empty before using an environment variable 2 years ago
options_test.go fix: Check if project is also empty before using an environment variable 2 years ago
smug.go set a custom timeout before executing send-keys for commands 2 years ago
smug_test.go fix: Fix creating manual windows 2 years ago
tmux.go refactor: Code cleanup & improvements 2 years ago

README.md

Smug - tmux session manager

Actions Status Go Report Card

Inspired by tmuxinator and tmuxp.

Smug automates your tmux workflow. You can create a single configuration file, and Smug will create all the required windows and panes from it.

gif

The configuration used in this GIF can be found here.

Installation

Download from the releases page

Download the latest version of Smug from the releases page and then run:

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

Fetch from GitHub

The easiest way is to clone Smug from GitHub and install it using go-cli:

cd /tmp
git clone https://github.com/ivaaaan/smug.git
cd smug
go install

macOS

On macOS, you can install Smug using MacPorts or Homebrew.

Homebrew

brew install smug

MacPorts

sudo port selfupdate
sudo port install smug

Linux

Arch

There's AUR with smug.

git clone https://aur.archlinux.org/smug.git
cd smug
makepkg -si

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
-i, --inside-current-session Create all windows inside current session
-d, --debug Print all commands to ~/.config/smug/smug.log
--detach Detach session. The same as `-d` flag in the tmux

Custom settings

You can pass custom settings into your configuration file. Use ${variable_name} syntax in your config and then pass key-value args:

xyz@localhost:~$ smug start project variable_name=value

Examples

To create a new project, or edit an existing one in the $EDITOR:

xyz@localhost:~$ smug new project

xyz@localhost:~$ smug edit project

To start/stop a project and all windows, run:

xyz@localhost:~$ smug start project

xyz@localhost:~$ smug stop project

Also, smug has aliases to the most of the commands:

xyz@localhost:~$ smug project # the same as "smug start project"

xyz@localhost:~$ smug st project # the same as "smug stop project"

xyz@localhost:~$ smug p ses # the same as "smug print ses"

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:

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

Also, you are not obliged to put your files in the ~/.config/smug directory. You can use a custom path in the -f flag:

xyz@localhost:~$ smug start -f ./project.yml

xyz@localhost:~$ smug stop -f ./project.yml

xyz@localhost:~$ smug start -f ./project.yml -w window1 -w window2

Configuration

Configuration files can stored in the ~/.config/smug directory in the YAML format, e.g ~/.config/smug/your_project.yml. You may also create a file named .smug.yml in the current working directory, which will be used by default.

Examples

Example 1

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`

env:
  FOO: BAR

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

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