An easy way to create, open, and close groupings of workspaces.
Add the following to your ~/.tmux.conf
:
# Download and use TWG
set -g @plugin 'stephencookdev/tmux-workspace-groupings'
# Set the workspace for TWG to use
set -g @groupings_workspace_directory /Users/batman/projects
Once saved, hit prefix + I to install.
Keybinding | Description |
---|---|
prefix + B | Opens the groupings create/swap menu |
prefix + b | Switch between sessions in the active group |
prefix + X | Close all windows, in all sessions, of the current grouping |
# The workspace TWG will use to look for projects
# (Required)
set -g @groupings_workspace_directory /Users/batman/projects
# The sessions to create for each project (comma separated)
# Default: 'build,git'
set -g @groupings_session_targets 'build,git,test'
# The min/max polling frequency of your file-system when running.
# TWG requires this to stay in sync with your workspace and tmux status
# Default for min: 1000 (1 second)
# Default for max: 15000 (15 seconds)
set -g @groupings_file_system_poll_min_interval 1000
set -g @groupings_file_system_poll_max_interval 15000
You can initalise panes with commands by creating some JSON config files.
For example, if you had a project called batman-work
in your workspace, then you could:
vi ~/.tmux/plugins/tmux-workspace-groupings/.config/batman-work.json
to create a file with contents:
{
"build": {
"layout": "even-horizontal",
"panes": ["echo 'i am'", "echo 'batman'"]
},
"git": {
"layout": "tiled",
"panes": ["git status", "git diff"]
}
}
Now whenever you open the batman-work
project, you will see:
- in the
build
session, two panes withecho 'i am'
andecho 'batman'
in each - in the
git
session, two panes withgit status
andgit diff
in each
If you want a pane with no command initialised, you can include the empty string, e.g. "panes": ["", ""]
The layout
is the name of a default tmux layout (i.e. it's a tmux thing, not a tmux-workspace-groupings thing).
Paste a GitHub URL into the create/swap menu to clone the repo into your workspace. TWG will also create a grouping for the new project.