chromakode / xkcdfools

xkcd CLI + jQuery terminal implementation
GNU General Public License v2.0
564 stars 116 forks source link

exit/C-d to go back a page #21

Closed duckinator closed 7 years ago

duckinator commented 14 years ago

I think exit or Ctrl+d should go to the previous page. And, if there is no previous page go back to xkcd.com (default page, not unixkcd)

duckinator commented 14 years ago

A tad hacky, but this will work for exit/Ctrl+d:

function exit_unixkcd() {
    history.back(); // Go back if you can, do nothing otherwise
    setTimeout('document.location = "http://xkcd.com";', 500); // If we're still here in 1/2 a second, go to xkcd.com
}

Note: the time (500) can likely be changed, i just tried that and it worked

sgbeal commented 14 years ago

You can hack that in to your local copy by doing:

TerminalShell.commands['logout'] = exit_unixkcd;

(That's how i've got mine set up.)

Handling Ctrl-D requires hacking cli.js. Search for 'h' (with the quotes) and you'll find it. Making those mappings configurable from client code is on my TODO list.