Skip to content

Instantly share code, notes, and snippets.

@ktravis
Last active Dec 20, 2015
Embed
What would you like to do?
Fish-do-last is dolast, for fish-shell.
# $ echo "kermit"
# kermit
# $ echo "fozzie bear"
# fozzie bear
# $ echo "miss piggy"
# miss piggy
# $ fdl 3
# kermit
# fozzie bear
# miss piggy
# [ fdl ignores calls to itself in history ]
# [ up-arrow ]
# $ fdl 3
# kermit
# fozzie bear
# miss piggy
function fdl
fish-do-last $argv
end
function fish-do-last
set x $argv[1]
if not set -q x # repeat one command if no arg
set x 1
end
for h in (history)
if begin echo $h | grep -q "fdl"
or echo $h | grep -q "fish-do-last"
end # fish, wtf
else
set x (echo "$x - 1" | bc)
set out "$h;$out"
end
if [ $x -lt 1 ]
break
end
end
eval $out
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment