Commit 3b913efd authored by Antoor's avatar Antoor Committed by GitHub

Merge pull request #73 from antoor/v2.0-beta-command-complete

v2.0-beta::command complete
parents f0873342 1fe0a7a2
......@@ -131,10 +131,12 @@ class Terminal {
// 初始化终端
this.term = dom.terminal( (cmd, term) => {
if (!cmd) { return false };
if (!cmd) { return false }
// 如果为exit||quit则关闭窗口
if (cmd === 'exit' || cmd === 'quit') { return this.cell.close() };
// term.pause();
if (cmd === 'exit' || cmd === 'quit') { return this.cell.close() }
// clear清空
if (cmd === 'cls' || cmd === 'clear') { return term.clear() }
term.pause();
// 是否有缓存
let cacheTag = 'command-' + new Buffer(this.path + cmd).toString('base64');
let cacheCmd = this.cache.get(cacheTag);
......@@ -196,7 +198,21 @@ class Terminal {
greetings: banner,
name: `terminal_${this.hash}`,
prompt: this.parsePrompt(infoUser),
exit: false
exit: false,
completion: (term, value, callback) => {
callback(
this.isWin ? [
'dir', 'whoami', 'net', 'ipconfig', 'netstat', 'cls',
'wscript', 'nslookup', 'copy', 'del', 'ren', 'md', 'type',
'ping'
] : [
'cd', 'ls', 'find', 'cp', 'mv', 'rm', 'ps', 'kill',
'file', 'tar', 'cat', 'chown', 'chmod', 'pwd', 'history',
'whoami', 'ifconfig', 'clear',
'ping'
]
)
}
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment