本文介绍了如何在Google Colab中运行shell(终端)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以调用支持的jQuery Terminal Emulator p>

这是一个


更新(7/2020)


我已将@Anant的答案添加到我的库中。现在,您可以轻松运行控制台,只需

 !pip从kora导入控制台安装kora 

console.start()#然后点击链接


I know that I can call !ls to issue ls command to shell.

But I want features like history or tab-completion.

Is it possible to do so in Google Colab?

解决方案

You can use jQuery Terminal Emulator backed with google.colab.kernel.invokeFunction

Here's an example notebook.

The key part is here, where you back it with shell function.

def shell(command):
  return JSON([getoutput(command)])
output.register_callback('shell', shell)

And here's how you use invokeFunction:

try {
    let res = await google.colab.kernel.invokeFunction('shell', [command])
    let out = res.data['application/json'][0]
    this.echo(new String(out))
} catch(e) {
    this.error(new String(e));
}

Here's a screenshot.

Update (7/2020)

I have taken @Anant's answer and add it into my library. Now you can run console easily with just

!pip install kora
from kora import console
console.start()  # and click link

这篇关于如何在Google Colab中运行shell(终端)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 04:44