Add bash profile

This commit is contained in:
Andrew Phillips
2023-09-18 14:29:38 +00:00
parent 292c0080d6
commit c100ef9436

51
profile.bash Executable file
View File

@@ -0,0 +1,51 @@
#!/bin/bash
function __keep_preexec {
KEEP_META_command="$1"
KEEP_META_directory=${KEEP_META_directory:-${PWD}}
KEEP_META_hostname=${KEEP_META_hostname:-${HOSTNAME:-$(hostname -f)}}
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
if [[ -z $KEEP_LIST_META ]]; then
export KEEP_LIST_META="hostname,command"
fi
}
function keep {
(
if [[ $BASH_SUBSHELL -eq 2 ]]; then
export KEEP_META_command
fi
export KEEP_META_directory
export KEEP_META_hostname
export KEEP_META_tty
exec keep "$@"
)
}
function @ {
keep --save "$@"
}
function @@ {
keep --get "$@"
}
__keep_preexec_init