Skip to content

Commit b27641f

Browse files
committed
feat: update readme and format
1 parent 9d735c8 commit b27641f

File tree

3 files changed

+86
-27
lines changed

3 files changed

+86
-27
lines changed

registry/anomaly/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
display_name: "Jay Kumar"
3-
bio: "Brief description of who you are and what you do"
3+
bio: "I'm a Software Engineer :)"
44
avatar_url: "./.images/avatar.png"
55
github: "35C4n0r"
6-
linkedin: "https://www.linkedin.com/in/jaykum4r" # Optional
7-
support_email: "work.jaykumar@gmail.co" # Optional
6+
linkedin: "https://www.linkedin.com/in/jaykum4r"
7+
support_email: "work.jaykumar@gmail.com"
88
status: "community"
99
---
1010

1111
# Your Name
1212

13-
Brief description of who you are and what you do.
13+
I'm a Software Engineer :)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# tmux Terraform Module
2+
3+
This module provisions and configures [tmux](https://github.com/tmux/tmux) with session persistence and plugin support
4+
for a Coder agent. It automatically installs tmux, the Tmux Plugin Manager (TPM), and a set of useful plugins, and sets
5+
up a default or custom tmux configuration with session save/restore capabilities.
6+
7+
## Features
8+
9+
- Installs tmux if not already present
10+
- Installs TPM (Tmux Plugin Manager)
11+
- Configures tmux with plugins for sensible defaults, session persistence, and automation:
12+
- `tmux-plugins/tpm`
13+
- `tmux-plugins/tmux-sensible`
14+
- `tmux-plugins/tmux-resurrect`
15+
- `tmux-plugins/tmux-continuum`
16+
- Supports custom tmux configuration
17+
- Enables automatic session save/restore
18+
- Configurable save interval
19+
20+
## Usage
21+
22+
```hcl
23+
module "tmux" {
24+
source = "path/to/this/module"
25+
agent_id = coder_agent.example.id
26+
tmux_config = "" # Optional: custom tmux.conf content
27+
save_interval = 1 # Optional: save interval in minutes
28+
}
29+
```
30+
31+
## Input Variables
32+
33+
| Name | Type | Description | Default |
34+
| ------------- | ------ | ----------------------------------- | ------- |
35+
| agent_id | string | The ID of a Coder agent. | n/a |
36+
| tmux_config | string | Custom tmux configuration to apply. | "" |
37+
| save_interval | number | Save interval (in minutes). | 1 |
38+
39+
## How It Works
40+
41+
- **tmux Installation:**
42+
- Checks if tmux is installed; if not, installs it using the system's package manager (supports apt, yum, dnf,
43+
zypper, apk, brew).
44+
- **TPM Installation:**
45+
- Installs the Tmux Plugin Manager (TPM) to `~/.tmux/plugins/tpm` if not already present.
46+
- **tmux Configuration:**
47+
- If `tmux_config` is provided, writes it to `~/.tmux.conf`.
48+
- Otherwise, generates a default configuration with plugin support and session persistence (using tmux-resurrect and
49+
tmux-continuum).
50+
- Sets up key bindings for quick session save (`Ctrl+s`) and restore (`Ctrl+r`).
51+
- **Plugin Installation:**
52+
- Installs plugins via TPM.
53+
- **Session Persistence:**
54+
- Enables automatic session save/restore at the configured interval.
55+
56+
## Example
57+
58+
```hcl
59+
module "tmux" {
60+
source = "./registry/anomaly/modules/tmux"
61+
agent_id = var.agent_id
62+
tmux_config = <<-EOT
63+
set -g mouse on
64+
set -g history-limit 10000
65+
EOT
66+
save_interval = 2
67+
}
68+
```
69+
70+
## Outputs
71+
72+
This module does not export outputs.
73+
74+
## Notes
75+
76+
- If you provide a custom `tmux_config`, it will completely replace the default configuration. Ensure you include plugin
77+
and TPM initialization lines if you want plugin support.
78+
- The script will attempt to install dependencies using `sudo` where required.
79+
- If `git` is not installed, TPM installation will fail.
80+
- If you are using custom config, you'll be responsible for setting up persistence

registry/anomaly/modules/tmux/main.tf

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,12 @@ variable "agent_id" {
1414
description = "The ID of a Coder agent."
1515
}
1616

17-
variable "session_name" {
18-
type = string
19-
description = "The name of the tmux session to create."
20-
default = "workspace"
21-
}
22-
23-
variable "startup_command" {
24-
type = string
25-
description = "Command to run when the tmux session starts."
26-
default = ""
27-
}
28-
2917
variable "tmux_config" {
3018
type = string
3119
description = "Custom tmux configuration to apply."
3220
default = ""
3321
}
3422

35-
variable "auto_attach" {
36-
type = bool
37-
description = "Whether to automatically attach to the tmux session when the app starts."
38-
default = true
39-
}
40-
4123
variable "save_interval" {
4224
type = number
4325
description = "Save interval (in minutes)."
@@ -49,11 +31,8 @@ resource "coder_script" "tmux" {
4931
display_name = "tmux"
5032
icon = "/icon/terminal.svg"
5133
script = templatefile("${path.module}/run.sh", {
52-
SESSION_NAME = var.session_name
53-
STARTUP_COMMAND = var.startup_command
54-
TMUX_CONFIG = var.tmux_config
55-
AUTO_ATTACH = var.auto_attach
56-
SAVE_INTERVAL = var.save_interval
34+
TMUX_CONFIG = var.tmux_config
35+
SAVE_INTERVAL = var.save_interval
5736
})
5837
run_on_start = true
5938
run_on_stop = false

0 commit comments

Comments
 (0)