An open API service indexing awesome lists of open source software.

https://github.com/en9inerd/zmx-scripts

Scripts to manage dev workflow under zmx + Ghostty
https://github.com/en9inerd/zmx-scripts

bash ghostty scripts sessions zmx

Last synced: 8 days ago
JSON representation

Scripts to manage dev workflow under zmx + Ghostty

Awesome Lists containing this project

README

          

# zmx-scripts

fzf-driven session picker and project workspace manager for [zmx](https://github.com/neurosnap/zmx), integrated with ghostty.

## Requirements

- [zmx](https://github.com/neurosnap/zmx)
- [fzf](https://github.com/junegunn/fzf)
- [fd](https://github.com/sharkdp/fd)
- ghostty

## Install

```bash
curl -fsSL https://raw.githubusercontent.com/en9inerd/zmx-scripts/master/install.sh | bash
```

Downloads scripts to `~/.local/bin/` and copies example config.

## ghostty config

Add to `~/.config/ghostty/config`:

```ghostty
shell-integration-features=no-cursor,no-sudo,ssh-terminfo,ssh-env
window-inherit-working-directory = true

keybind = ctrl+b>f=text:zmx-sessionizer\n
keybind = ctrl+b>w=text:zmx-workspace attach\n
keybind = ctrl+b>x=text:zmx kill $ZMX_SESSION\n
keybind = ctrl+b>shift+x=text:zws kill-session\n
```

## zshrc

Append to `~/.zshrc`:

```zsh
alias zws='zmx-workspace'
alias zs='zmx-sessionizer'

source <(zmx completions zsh)

[[ -n "$ZMX_SESSION" ]] && GHOSTTY_SHELL_FEATURES=${(j:,:)${(s:,:)GHOSTTY_SHELL_FEATURES:#title}}
_zmx_title() { [[ -n "$ZMX_SESSION" ]] && printf '\e]0;%s\a' "$ZMX_SESSION"; }
precmd_functions+=(_zmx_title)
```

Inside zmx sessions, strips `title` from `GHOSTTY_SHELL_FEATURES` before ghostty's deferred init runs — preventing ghostty from installing title hooks. `_zmx_title` then owns the tab title exclusively. Plain shells are unaffected. `precmd_functions+=` must be last in `.zshrc`.

## sessionizer config

Edit `~/.config/zmx-sessionizer/zmx-sessionizer.conf`:

```bash
# ZMX_SEARCH_PATHS=(~/Development) # default
# ZMX_SEARCH_PATHS=(~/Development ~/Work:2)
# ZMX_MAX_DEPTH=1
```

## Usage

### zmx-workspace

```bash
zws new # create project (name + dir + sessions)
zws open [project] # start all sessions for project
zws attach [project] # fzf pick — flat list of all sessions across all projects, lazy-creates if missing
zws list # all projects with session counts
zws kill [project] # kill all sessions for project
zws kill-session # fzf pick and kill any single session
zws delete [project] # kill all sessions and remove project config
```

Project config format (`~/.config/zmx-sessionizer/workspaces/.conf`):

```bash
ZMX_DIR=/path/to/project
ZMX_SESSIONS=(
"editor:nvim ."
"server:npm start"
"shell:"
)
```

### Keybinds

| Key | Action |
|----------------|-------------------------------|
| Cmd+T | new tab (plain shell) |
| ctrl+b f | session picker (fzf) |
| ctrl+b w | session picker (all projects) |
| ctrl+b x | kill current session |
| ctrl+b X | fzf pick and kill any session |
| ctrl+\ | detach from session |