I just grep through my bash history ;)
alias sl='fc -ln -1 | sed "s/^\s*//" >> ~/.saved_commands.txt'
alias slg='< ~/.saved_commands.txt grep'
You can also add a comment to the command before saving. For ex: $ foo_cmd args #this command does this awesome thing
$ sl #!/bin/bash
size=${1:-"1920x1080"}
offset=${2:-"0,0"}
name=${3:-"video"}
ffmpeg -video_size $size -framerate 25 -f x11grab -i :0.0+$offset -c:v libx264 -crf 0 -preset ultrafast "$name.mkv"
ffmpeg -i "$name.mkv" -movflags faststart -pix_fmt yuv420p "$name.mp4" echo ‘!!’ > ~/bin/name-of-script
where !! is the previous command