mirror of
https://github.com/Gu1llaum-3/sshm.git
synced 2026-01-27 03:04:21 +01:00
feat: add shell completion for host names (#37)
- Add ValidArgsFunction to RootCmd for dynamic host completion - Add 'sshm completion' subcommand for bash/zsh/fish/powershell - Support prefix matching and case-insensitive filtering - Respect --config flag for custom SSH config files - Add comprehensive tests for completion functionality - Document setup instructions in README Co-authored-by: Guillaume Archambault <67098259+Gu1llaum-3@users.noreply.github.com>
This commit is contained in:
47
README.md
47
README.md
@@ -275,6 +275,53 @@ sshm --version
|
||||
sshm --help
|
||||
```
|
||||
|
||||
### Shell Completion
|
||||
|
||||
SSHM supports shell completion for host names, making it easy to connect to hosts without typing full names:
|
||||
|
||||
```bash
|
||||
sshm <TAB> # Lists all available hosts
|
||||
sshm pro<TAB> # Completes to hosts starting with "pro" (e.g., prod-server)
|
||||
```
|
||||
|
||||
**Setup Instructions:**
|
||||
|
||||
**Bash:**
|
||||
```bash
|
||||
# Enable for current session
|
||||
source <(sshm completion bash)
|
||||
|
||||
# Enable permanently (add to ~/.bashrc)
|
||||
echo 'source <(sshm completion bash)' >> ~/.bashrc
|
||||
```
|
||||
|
||||
**Zsh:**
|
||||
```bash
|
||||
# Enable for current session
|
||||
source <(sshm completion zsh)
|
||||
|
||||
# Enable permanently (add to ~/.zshrc)
|
||||
echo 'source <(sshm completion zsh)' >> ~/.zshrc
|
||||
```
|
||||
|
||||
**Fish:**
|
||||
```bash
|
||||
# Enable for current session
|
||||
sshm completion fish | source
|
||||
|
||||
# Enable permanently
|
||||
sshm completion fish > ~/.config/fish/completions/sshm.fish
|
||||
```
|
||||
|
||||
**PowerShell:**
|
||||
```powershell
|
||||
# Enable for current session
|
||||
sshm completion powershell | Out-String | Invoke-Expression
|
||||
|
||||
# Enable permanently (add to your PowerShell profile)
|
||||
Add-Content $PROFILE 'sshm completion powershell | Out-String | Invoke-Expression'
|
||||
```
|
||||
|
||||
### Direct Host Connection
|
||||
|
||||
SSHM supports direct connection to hosts via the command line, making it easy to integrate into your existing workflow:
|
||||
|
||||
Reference in New Issue
Block a user