There is no easy way to do it... and you have to use
eval(0), unfortunately.
Put this in your
.bashrc file:
Code:
oops() {
local line
read -r line < <(fc -lnr)
if [[ $line = *\ * ]]; then
eval "$1 ${line#*[[:blank:]]}"
else
eval "$1"
fi
}
Here is the one-line version:
Code:
oops() { local line; read -r line < <(fc -lnr); [[ $line = *\ * ]] && eval "$1 ${line#*[[:blank:]]}" || eval "$1"; }
------
« Ego is a structure that is erected by a neurotic individual who is a
member of a neurotic culture against the facts of the matter. And
culture, which we put on like an overcoat, is the collectivized consensus
about what sort of neurotic behaviors are acceptable. » --
Terence McKenna