zdcthomas / dmux

A tmux workspace manager
MIT License
310 stars 6 forks source link

DMUX

(Development tMUX)

new names definitely being considered

What is this?

If you use tmux a lot, then you probably have a script that looks like this:

tmux new-window -n $WINDOW_NAME
tmux split-window -h
tmux select-pane -t 0
tmux send-keys "fish" C-m
tmux send-keys "nvim" C-m
tmux select-pane -t 1
tmux send-keys "fish" C-m
tmux resize-pane -R 80
tmux -2 attach-session -t $SESSION

Scripts like the one above set up and open a tmux session with specified commands and layout. But if I wanted to have another pane that ran my tests, or another for note taking, I'd have to create an entirely new script. I also wanted to be able to use some program like fzf or skim to pick a directory to open. This got super annoying.

Dmux aims to handle all of this for you. Its main job is to open up configurable "workspaces" in whatever directory you want. It also allows you to specify everything you would normally set in a script like the one above.

For example, the above script using dmux would be: dmux -c nvim fish <path> Then if I wanted the workspace to open 3 panes instead of two, I could add: dmux -c nvim fish "npm i" -p 3 <path>

But say I wanted to use fzf to select a dir to open up. Well, if I have it installed on my system, then I just have to leave off the argument and dmux will automatically open an fzf selector, populated with directories to choose from.

If this part is a bit slow to get started, no worries, you can speed up the dir searching by installing fd.

You can also use whatever combination of dir searching, selector, or hardcoded path you want by piping a path into dmux: fd -td | fzf | dmux or having a path argument: dmux <path>

Why another Tmux Manager?

There's a ton of other fantastic projects out there that also do similar things that you should check out:

So Why did I put together Dmux?

Installation

macOS
brew tap zdcthomas/tools
brew install dmux

Or if you have rust installed

cargo install dmux
AUR
Coming soon

Usage

Configuration

Dmux's configuration tries to be very inclusive in terms of config file types. Dmux supports JSON, YAML, TOML, and HJSON. It also supports a variety of paths including ~/.dmux.conf.{file_type} ~/.config/dmux/dmux.conf.{file_type} and on Linux $XDG_CONFIG_HOME/dmux/dmux.conf.{file_type}

Example Configuration File

This config file has a profile named javascript and defaults set

TOML
layout = "5e09,281x67,0,0{133x67,0,0,17,147x67,134,0[147x33,134,0,18,147x33,134,34{73x33,134,34,136,73x33,208,34[73x16,208,34,164,73x16,208,51,165]}]}"
session_name = "development"
number_of_panes = 5
commands = ["nvim", "fish"]

[javascript]
number_of_panes = 3
session_name = "frontend"
commands = ["nvim", "fish", "yarn watch"]

External deps

Currently dmux relies on fzf to select a target dir to open the workspace in. If you have fd installed dmux will use it to speed up dir searching.

Potential features

Bugs

please submit bugs as issues and I'll add them here