Skip to content

Instantly share code, notes, and snippets.

@ktravis
Last active December 20, 2015 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ktravis/6165999 to your computer and use it in GitHub Desktop.
Save ktravis/6165999 to your computer and use it in GitHub Desktop.
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