Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
.PHONY: test test-verbose install clean
.PHONY: test install clean

test:
@bats tests/

test-verbose:
@bats -t tests/

install:
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ tmux-ws create project
# Create in background, stay in current shell
tmux-ws create project --detach

# Attach to a running workspace
tmux-ws attach project

# List what's available and what's running
tmux-ws list

Expand Down Expand Up @@ -145,11 +148,10 @@ Directories starting with `_` (like `_templates`, `_examples`) are hidden from `
## Testing

```bash
make test # run test suite
make test-verbose # run with trace output
make test
```

Requires [bats](https://github.com/bats-core/bats-core). Tests cover: help, version, list, create, inheritance, hooks, validation, kill, edit, and init.
Requires [bats](https://github.com/bats-core/bats-core). Tests cover: help, version, list, create, inheritance, hooks, validation, kill, attach, edit, and init.

## tmux Configuration

Expand Down
34 changes: 34 additions & 0 deletions completions/tmux-ws.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# Bash completion for tmux-ws

_tmux_ws() {
local config_dir="${TMUX_WS_CONFIG:-$HOME/.config/tmux-ws}"
local cur="${COMP_WORDS[COMP_CWORD]}"
local prev="${COMP_WORDS[COMP_CWORD-1]}"
local subcommands="create attach list kill edit init help version"

# First argument: complete subcommands
if [[ $COMP_CWORD -eq 1 ]]; then
COMPREPLY=($(compgen -W "$subcommands" -- "$cur"))
return
fi

# Second argument: complete workspace names for commands that take them
if [[ $COMP_CWORD -eq 2 ]]; then
case "$prev" in
create|attach|kill|edit)
local workspaces=""
for dir in "$config_dir"/*/; do
[[ ! -f "$dir/workspace.conf" ]] && continue
local name
name=$(basename "$dir")
[[ "$name" == _* ]] && continue
workspaces="$workspaces $name"
done
COMPREPLY=($(compgen -W "$workspaces" -- "$cur"))
;;
esac
fi
}

complete -F _tmux_ws tmux-ws
35 changes: 35 additions & 0 deletions completions/tmux-ws.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#compdef tmux-ws

# Zsh completion for tmux-ws

_tmux_ws() {
local config_dir="${TMUX_WS_CONFIG:-$HOME/.config/tmux-ws}"
local subcommands=(create attach list kill edit init help version)

_arguments -C \
'1:subcommand:->subcommand' \
'2:workspace:->workspace' \
&& return

case $state in
subcommand)
compadd -a subcommands
;;
workspace)
case $words[2] in
create|attach|kill|edit)
local -a workspaces
for dir in "$config_dir"/*/; do
[[ ! -f "$dir/workspace.conf" ]] && continue
local name="${dir:t}"
[[ "$name" == _* ]] && continue
workspaces+=("$name")
done
compadd -a workspaces
;;
esac
;;
esac
}

_tmux_ws "$@"
33 changes: 33 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,39 @@ else
warn "No .bashrc or .zshrc found — add $BIN_DIR to your PATH manually"
fi

# Install shell completions
COMPLETIONS_SRC="$SCRIPT_DIR/completions"

# Bash completion
if [[ -f "$HOME/.bashrc" ]]; then
if ! grep -qF "tmux-ws.bash" "$HOME/.bashrc" 2>/dev/null; then
echo "" >> "$HOME/.bashrc"
echo "# tmux-ws completion" >> "$HOME/.bashrc"
echo "source \"$COMPLETIONS_SRC/tmux-ws.bash\"" >> "$HOME/.bashrc"
info "Bash completion added to ~/.bashrc"
else
warn "Bash completion already configured in ~/.bashrc"
fi
fi

# Zsh completion
if [[ -f "$HOME/.zshrc" ]]; then
ZSH_COMPLETIONS_DIR="$HOME/.zsh/completions"
mkdir -p "$ZSH_COMPLETIONS_DIR"
cp "$COMPLETIONS_SRC/tmux-ws.zsh" "$ZSH_COMPLETIONS_DIR/_tmux-ws"
info "Zsh completion installed to $ZSH_COMPLETIONS_DIR"

if ! grep -qF "zsh/completions" "$HOME/.zshrc" 2>/dev/null; then
echo "" >> "$HOME/.zshrc"
echo "# tmux-ws completion" >> "$HOME/.zshrc"
echo "fpath=($ZSH_COMPLETIONS_DIR \$fpath)" >> "$HOME/.zshrc"
echo "autoload -Uz compinit && compinit" >> "$HOME/.zshrc"
info "Zsh completion configured in ~/.zshrc"
else
warn "Zsh fpath already configured in ~/.zshrc"
fi
fi

# Make script executable
chmod +x "$BIN_DIR/tmux-ws"

Expand Down
Loading