You can add it in .bashrc.
---- alias mm='MC=`expr $MC + 1`; alias g$MC="$(history -p !!)"; echo `alias g$MC`' alias gg='eval g$MC' alias lg="alias | grep -e '^alias g[0-9]'" ---- 'mm' command saves the latest command you type. 'gg' command calls the saved command. 'lg' command show the list of saved command.