48 lines
814 B
Bash
Executable File
48 lines
814 B
Bash
Executable File
#!/bin/bash
|
|
|
|
export KEEP_LIST_FORMAT="${KEEP_LIST_FORMAT:-id,time,size,tags,meta:full_hostname,meta:file_magic,meta:command}"
|
|
export KEEP_META_PLUGINS="${KEEP_META_PLUGINS:-binary,cwd,file_magic,full_hostname}"
|
|
|
|
|
|
function __keep_preexec {
|
|
KEEP_META_command="$1"
|
|
KEEP_META_tty=${KEEP_META_tty:-$(tty)}
|
|
}
|
|
|
|
function __keep_preexec_init {
|
|
local found=false
|
|
local f
|
|
for f in "${preexec_functions[@]}"; do
|
|
if [[ $f = __keep_preexec ]]; then
|
|
found=true
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [[ $found = false ]]; then
|
|
preexec_functions+=(__keep_preexec)
|
|
fi
|
|
}
|
|
|
|
function keep {
|
|
(
|
|
if [[ $BASH_SUBSHELL -le 2 ]]; then
|
|
export KEEP_META_command
|
|
fi
|
|
|
|
export KEEP_META_tty
|
|
|
|
exec keep "$@"
|
|
)
|
|
}
|
|
|
|
function @ {
|
|
keep --save "$@"
|
|
}
|
|
|
|
function @@ {
|
|
keep --get "$@"
|
|
}
|
|
|
|
__keep_preexec_init
|