Add replay function

This commit is contained in:
David Todd
2020-03-24 14:55:38 -05:00
parent 3092e88e60
commit 9dc69b2e1c
2 changed files with 12 additions and 1 deletions

View File

@@ -65,3 +65,14 @@ up() {
search () {
grep -r "$1" | fzf
}
# Usage: replay <number of commands> to repeat. Blank for 1
replay() {
from="${1:-2}"
to="${2:-1}"
if [ "$from" -ne "$to" ]; then
for i in `seq "$from" -1 "$(($to + 1))"`; do
printf "$(fc -ln -${i} -${i}) && "
done
fi
$(fc -ln -${to} -${to})
}