ed exec
This commit is contained in:
18
users/pbsds/home/profiles/bashrc.d/edex.sh
Normal file
18
users/pbsds/home/profiles/bashrc.d/edex.sh
Normal file
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user