feat: add shell profiles for zsh, sh, csh/tcsh
- profile.bash: simplified preexec_init (early return), extracted ___keep_complete helper for @/@@ completion wrappers - profile.zsh: add-zsh-hook preexec, wrapper function, @/@@ aliases, completions via compdef - profile.sh: POSIX-compatible for sh/dash/ksh. Wrapper function, @/@@ aliases. No preexec or completions. - profile.csh: alias-based keep wrapper, @/@@ aliases. No preexec or completions. - modulefile: adds KEEP_SH_PROFILE, KEEP_ZSH_PROFILE, KEEP_CSH_PROFILE - README: updated Shell Integration table and Shell Completion section
This commit is contained in:
47
README.md
47
README.md
@@ -85,14 +85,24 @@ module load keep
|
||||
keep --status
|
||||
|
||||
# Source the shell profile (optional, for shell integration)
|
||||
source $KEEP_BASH_PROFILE
|
||||
source $KEEP_BASH_PROFILE # bash
|
||||
source $KEEP_ZSH_PROFILE # zsh
|
||||
source $KEEP_SH_PROFILE # sh/dash/ksh
|
||||
source $KEEP_CSH_PROFILE # csh/tcsh
|
||||
```
|
||||
|
||||
The modulefile prepends `keep/bin` to `PATH` and sets `KEEP_BASH_PROFILE` pointing to `profile.bash`.
|
||||
The modulefile prepends `keep/bin` to `PATH` and sets shell-specific profile variables:
|
||||
|
||||
| Variable | Profile | Shell |
|
||||
|----------|---------|-------|
|
||||
| `KEEP_BASH_PROFILE` | `profile.bash` | bash |
|
||||
| `KEEP_ZSH_PROFILE` | `profile.zsh` | zsh |
|
||||
| `KEEP_SH_PROFILE` | `profile.sh` | sh, dash, ksh93, pdksh, mksh |
|
||||
| `KEEP_CSH_PROFILE` | `profile.csh` | csh, tcsh |
|
||||
|
||||
### Shell Completion
|
||||
|
||||
Tab completion is available for `bash`, `zsh`, `fish`, `elvish`, and `powershell`.
|
||||
Tab completion is available for `bash`, `zsh`, `fish`, `elvish`, and `powershell`. Completions for `@` (save) and `@@` (get) are available for `bash` and `zsh` only.
|
||||
|
||||
**Bash** — add to `~/.bashrc`:
|
||||
|
||||
@@ -106,7 +116,7 @@ Tab completion is available for `bash`, `zsh`, `fish`, `elvish`, and `powershell
|
||||
. <(keep --generate-completion zsh)
|
||||
```
|
||||
|
||||
**With `profile.bash`**: Completions for `keep`, `@` (save), and `@@` (get) are loaded automatically when sourcing `profile.bash`.
|
||||
**With `profile.bash` or `profile.zsh`**: Completions for `keep`, `@` (save), and `@@` (get) are loaded automatically when sourcing the profile.
|
||||
|
||||
### Build with Server/Client Features
|
||||
|
||||
@@ -848,20 +858,41 @@ The server applies the following security measures:
|
||||
|
||||
## Shell Integration
|
||||
|
||||
Source `profile.bash` to enable shell integration:
|
||||
Profile scripts are provided for several shells. Source the appropriate one to enable shell integration:
|
||||
|
||||
| Profile | Shells | Features |
|
||||
|---------|--------|----------|
|
||||
| `profile.bash` | bash | Preexec hook, wrapper function, `@`/`@@` aliases, tab completions |
|
||||
| `profile.zsh` | zsh | Preexec hook, wrapper function, `@`/`@@` aliases, tab completions |
|
||||
| `profile.sh` | sh, dash, ksh93, pdksh, mksh | Wrapper function, `@`/`@@` aliases |
|
||||
| `profile.csh` | csh, tcsh | Alias-based `keep` wrapper, `@`/`@@` aliases |
|
||||
|
||||
```sh
|
||||
# bash
|
||||
source /path/to/keep/profile.bash
|
||||
|
||||
# zsh
|
||||
source /path/to/keep/profile.zsh
|
||||
|
||||
# sh, dash, ksh
|
||||
source /path/to/keep/profile.sh
|
||||
|
||||
# csh/tcsh
|
||||
source /path/to/keep/profile.csh
|
||||
```
|
||||
|
||||
This provides:
|
||||
All profiles provide:
|
||||
|
||||
- **`keep` function** — Captures the current command in metadata automatically
|
||||
- **`@` alias** — Shorthand for `keep --save`
|
||||
- **`@@` alias** — Shorthand for `keep --get`
|
||||
|
||||
Bash and zsh profiles additionally provide:
|
||||
|
||||
- **`keep` function** — Captures the current command in metadata automatically
|
||||
- **Tab completion** — For `keep`, `@`, and `@@`
|
||||
|
||||
```sh
|
||||
# Save with automatic command capture
|
||||
# Save with automatic command capture (bash/zsh)
|
||||
curl -s api.example.com | @ api-response
|
||||
|
||||
# Quick retrieve
|
||||
|
||||
Reference in New Issue
Block a user