Adds shell integration for automatic Gas Town context detection. Features: - `gt enable` / `gt disable` - Global on/off switch - `gt shell install|remove|status` - Shell integration management - `gt rig quick-add [path]` - One-command project setup - `gt uninstall` - Clean removal with options - Shell hook auto-sets GT_TOWN_ROOT/GT_RIG on cd Implementation: - XDG-compliant state storage (~/.local/state/gastown/) - Safe RC file manipulation with block markers - Environment overrides (GASTOWN_DISABLED/ENABLED) - Doctor check for global state validation Co-authored-by: Sohail Mohammad <sohailm25@gmail.com>
73 lines
1.8 KiB
Go
73 lines
1.8 KiB
Go
// ABOUTME: Command to disable Gas Town system-wide.
|
|
// ABOUTME: Sets the global state to disabled so tools work vanilla.
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/steveyegge/gastown/internal/shell"
|
|
"github.com/steveyegge/gastown/internal/state"
|
|
"github.com/steveyegge/gastown/internal/style"
|
|
)
|
|
|
|
var disableClean bool
|
|
|
|
var disableCmd = &cobra.Command{
|
|
Use: "disable",
|
|
GroupID: GroupConfig,
|
|
Short: "Disable Gas Town system-wide",
|
|
Long: `Disable Gas Town for all agentic coding tools.
|
|
|
|
When disabled:
|
|
- Shell hooks become no-ops
|
|
- Claude Code SessionStart hooks skip 'gt prime'
|
|
- Tools work 100% vanilla (no Gas Town behavior)
|
|
|
|
The workspace (~/gt) is preserved. Use 'gt enable' to re-enable.
|
|
|
|
Flags:
|
|
--clean Also remove shell integration from ~/.zshrc/~/.bashrc
|
|
|
|
Environment overrides still work:
|
|
GASTOWN_ENABLED=1 - Enable for current session only`,
|
|
RunE: runDisable,
|
|
}
|
|
|
|
func init() {
|
|
disableCmd.Flags().BoolVar(&disableClean, "clean", false,
|
|
"Remove shell integration from RC files")
|
|
rootCmd.AddCommand(disableCmd)
|
|
}
|
|
|
|
func runDisable(cmd *cobra.Command, args []string) error {
|
|
if err := state.Disable(); err != nil {
|
|
return fmt.Errorf("disabling Gas Town: %w", err)
|
|
}
|
|
|
|
if disableClean {
|
|
if err := removeShellIntegration(); err != nil {
|
|
fmt.Printf("%s Could not clean shell integration: %v\n",
|
|
style.Warning.Render("!"), err)
|
|
} else {
|
|
fmt.Println(" Removed shell integration from RC files")
|
|
}
|
|
}
|
|
|
|
fmt.Printf("%s Gas Town disabled\n", style.Success.Render("✓"))
|
|
fmt.Println()
|
|
fmt.Println("All agentic coding tools now work vanilla.")
|
|
if !disableClean {
|
|
fmt.Printf("Use %s to also remove shell hooks\n",
|
|
style.Dim.Render("gt disable --clean"))
|
|
}
|
|
fmt.Printf("Use %s to re-enable\n", style.Dim.Render("gt enable"))
|
|
|
|
return nil
|
|
}
|
|
|
|
func removeShellIntegration() error {
|
|
return shell.Remove()
|
|
}
|