diff --git a/users/pbsds/home/profiles/bashrc.d/edex.sh b/users/pbsds/home/profiles/bashrc.d/edex.sh new file mode 100644 index 0000000..6214086 --- /dev/null +++ b/users/pbsds/home/profiles/bashrc.d/edex.sh @@ -0,0 +1,18 @@ +edex() { + local fname="$(mktemp)" + cat >"$fname" + local epoch="$(mktemp)" + trap 'rm "$epoch" >&/dev/null' RETURN ERR + + "$EDITOR" "$fname" >&2 || return 1 + + # check mtime to ensure the editor has saved + if [[ -s "$fname" && "$fname" -nt "$epoch" ]]; then + # history -s ". $(printf "%q" "$fname")" + printf >&2 "edex: commands are save to %q\n" "$fname" + . "$fname" + else + printf >&2 "%s\n" "edex: File not saved, hence not run" + return 1 + fi +}