tenseleyflow/gitswitch / 6210af9

Browse files

docs: document shell integration and init subcommand

Authored by espadonne
SHA
6210af9cbf073d76c63f320dbe33f2b9cb050334
Parents
b4f7c27
Tree
4a714c8

1 changed file

StatusFile+-
M README.md 31 0
README.mdmodified
@@ -14,6 +14,7 @@ Commands:
1414
   status               Show current account status
1515
   doctor, health       Run comprehensive health check
1616
   config               Show configuration file information
17
+  init <shell>         Emit shell integration (fish|bash|zsh|sh)
1718
   <account>            Switch to specified account
1819
 
1920
 Options:
@@ -35,3 +36,33 @@ Examples:
3536
   gitswitch remove 2               # Remove account ID 2
3637
   gitswitch doctor                 # Run health check
3738
 ```
39
+
40
+## shell integration
41
+
42
+gitswitch maintains a stable SSH agent socket at a fixed path so your shell
43
+can point `SSH_AUTH_SOCK` at it once and have every `gitswitch <account>`
44
+switch transparently. Add the matching line to your shell rc:
45
+
46
+```fish
47
+# ~/.config/fish/config.fish
48
+gitswitch init fish | source
49
+```
50
+
51
+```bash
52
+# ~/.bashrc
53
+eval "$(gitswitch init bash)"
54
+```
55
+
56
+```zsh
57
+# ~/.zshrc
58
+eval "$(gitswitch init zsh)"
59
+```
60
+
61
+The snippet guards on the socket's existence, so sourcing it before the
62
+first switch (or after `/tmp` has been wiped) is a silent no-op rather than
63
+an error.
64
+
65
+> **Migrating from the Python gitswitch?** The old `gitswitch --ssh-agent-info`
66
+> invocation still works as a compat alias that auto-detects your shell from
67
+> `$SHELL`, but prefer the explicit `init <shell>` form in new rc files.
68
+