Tip - Running Commands From Anywhere in jQuery Console

I recently had javascript tests that required me to execute commands in a jQuery Terminal console which turned out to be more complicated that thought.

jQuery Terminal is a handy terminal Emulator that allows creating command line interpreters within the web browser.

If a active terminal is present onscreen we can access it from anywhere using the $.terminal.active() function, we can then use the exec function to run a passed in string like so:

$.terminal.active().exec('ls -al');

Various jQuery Terminal functions can be chained to active like exec such as clear or enabled, they are listed here: API Reference