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:
38
profile.zsh
Normal file
38
profile.zsh
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/bin/zsh
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
|
||||
__keep_preexec() {
|
||||
KEEP_META_command="$1"
|
||||
KEEP_META_tty=${KEEP_META_tty:-$(tty)}
|
||||
}
|
||||
|
||||
add-zsh-hook preexec __keep_preexec
|
||||
|
||||
keep() {
|
||||
if [[ $ZSH_SUBSHELL -le 2 ]]; then
|
||||
export KEEP_META_command
|
||||
fi
|
||||
export KEEP_META_tty
|
||||
command keep "$@"
|
||||
}
|
||||
|
||||
alias @='keep --save'
|
||||
alias @@='keep --get'
|
||||
|
||||
# Shell completions
|
||||
. <(command keep --generate-completion zsh)
|
||||
|
||||
___keep_complete() {
|
||||
local mode="$1"
|
||||
local -a words
|
||||
words=(keep "$mode" "${words[@]:1}")
|
||||
((CURRENT++))
|
||||
_keep
|
||||
}
|
||||
|
||||
___keep_save_completion() { ___keep_complete --save; }
|
||||
___keep_get_completion() { ___keep_complete --get; }
|
||||
|
||||
compdef ___keep_save_completion @
|
||||
compdef ___keep_get_completion @@
|
||||
Reference in New Issue
Block a user