#!/bin/bash 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