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:
24
profile.bash
24
profile.bash
@@ -6,18 +6,10 @@ function __keep_preexec {
|
||||
}
|
||||
|
||||
function __keep_preexec_init {
|
||||
local found=false
|
||||
local f
|
||||
for f in "${preexec_functions[@]}"; do
|
||||
if [[ $f = __keep_preexec ]]; then
|
||||
found=true
|
||||
break
|
||||
fi
|
||||
[[ $f = __keep_preexec ]] && return
|
||||
done
|
||||
|
||||
if [[ $found = false ]]; then
|
||||
preexec_functions+=(__keep_preexec)
|
||||
fi
|
||||
preexec_functions+=(__keep_preexec)
|
||||
}
|
||||
|
||||
function keep {
|
||||
@@ -43,17 +35,15 @@ function @@ {
|
||||
# Shell completions
|
||||
. <(command keep --generate-completion bash)
|
||||
|
||||
___keep_save_completion() {
|
||||
COMP_WORDS=(keep --save "${COMP_WORDS[@]:1}")
|
||||
___keep_complete() {
|
||||
local mode="$1"
|
||||
COMP_WORDS=(keep "$mode" "${COMP_WORDS[@]:1}")
|
||||
COMP_CWORD=$((COMP_CWORD + 1))
|
||||
_keep
|
||||
}
|
||||
|
||||
___keep_get_completion() {
|
||||
COMP_WORDS=(keep --get "${COMP_WORDS[@]:1}")
|
||||
COMP_CWORD=$((COMP_CWORD + 1))
|
||||
_keep
|
||||
}
|
||||
___keep_save_completion() { ___keep_complete --save; }
|
||||
___keep_get_completion() { ___keep_complete --get; }
|
||||
|
||||
complete -F ___keep_save_completion @
|
||||
complete -F ___keep_get_completion @@
|
||||
|
||||
Reference in New Issue
Block a user