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:
14
   status               Show current account status
14
   status               Show current account status
15
   doctor, health       Run comprehensive health check
15
   doctor, health       Run comprehensive health check
16
   config               Show configuration file information
16
   config               Show configuration file information
17
+  init <shell>         Emit shell integration (fish|bash|zsh|sh)
17
   <account>            Switch to specified account
18
   <account>            Switch to specified account
18
 
19
 
19
 Options:
20
 Options:
@@ -35,3 +36,33 @@ Examples:
35
   gitswitch remove 2               # Remove account ID 2
36
   gitswitch remove 2               # Remove account ID 2
36
   gitswitch doctor                 # Run health check
37
   gitswitch doctor                 # Run health check
37
 ```
38
 ```
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
+