jquery.terminal
jquery.terminal copied to clipboard
Multi-word commands
I have question related to jQuery Terminal
How do you make commands multiple words? I'm trying to make a joke "sudo rm -rf" command but when I try it, it only says "command sudo not fount"
there are two ways:
$('...').terminal(function(command) {
// command will be "sudo rm -rf"
// but it will not work if something type double space between sudo and rm or rm and -rf
});
or you can use this:
$('...').terminal({
sudo: function(command, ...args) {
// command will be rm and args will be ["-rf"]
}
});
with second usage you can handle different commands like:
if (command == 'rm') {
} else if (command == 'mv') {
} else if (command ==='cp') {
}
or use any logic you want.
With first you will need to parse the command yourself. but there are also helpers for that like $.terminal.parse_command or $.terminal.split_command (split will not change "10" into 10). All functions are in api reference page. But I need to work a bit on documentation, maybe some tutorials.
Also to make ...args working you will need checkArity: false because by default the library is checking how many arguments you have.
@SynergyBest please do not close this issue, I use it to remember to add this to documentation.
Oh, sorry!