2

Does anyone know how to prevent a command from going into history in JQuery Terminal? That is, when a command is typed it triggers my :

var term = $('body').terminal(
  function(command) {
    //stuff here for dealing with the contents of 'command'.
  }

Main hander function. When this function returns, terminal will then insert a line on the page and display a new prompt line underneath.

What I want to do (optionally) is say 'this command I've intercepted and worked on doesn't need to go into history'.

Alternatively how can I delete the last command from history?

Is that possible?

Edit: By way of avoiding XY problems: The task I'm trying to achieve is to create a terminal, and then on behalf of the user, enter commands. Ideally entry of the commands would be animated (a delay between letters). It's nearly working but not quite.

Richard
  • 1,070
  • 9
  • 22
  • By history, do you mean the output on the terminal? Because there is another history called History when you press the up arrow it will show you the commands that you previously type. – jcubic Sep 22 '22 at 16:31
  • 1
    To disable adding a command into output you can use `echoCommand` option. To disable command line history you can use `history` or `historyFilter` first is a boolean value second is a function that returns boolean. – jcubic Sep 22 '22 at 16:36
  • @jcubic yes.. the output on the terminal, not the 'up and down arrow' history (like bash). Sorry – Richard Sep 22 '22 at 16:47
  • Then you need to use `echoCommand: false` option and if you want to have the command appear conditionally you will need to echo it yourself. – jcubic Sep 22 '22 at 16:56
  • @jcubic Sorry to bother you.. Is there a 'function' for this, ie something like term.setEcho(false) etc.? I can't find it in the docs. – Richard Sep 22 '22 at 17:03
  • 1
    There is a method `option()` to change the settings, but I think that it's missing in API Reference. It's in the TypeScript definition file. Here is an example https://codepen.io/jcubic/pen/dyeVeGb – jcubic Sep 23 '22 at 15:51
  • 1
    @jcubic Great work BTW – Richard Sep 25 '22 at 13:05

0 Answers0