❏ 站外平台:

Betty:和你的Linux说说话

作者: SK 译者: LCTT Rekii

| 2014-07-23 14:02   评论: 19 分享: 7    

Betty 是一个将类英语短语翻译成Linux命令的开源工具。这个项目的主要目的是让大家可以通过输入自然语言来使用强大的Linux系统。让我们来看一下它是怎么工作的。

安装

Betty的安装非常简单直接。首先确认你已经安装了下面这些依赖包[LCTT译注,需要安装至少Ruby1.9以上版本]。

对于基于Debian的系统:

sudo apt-get install git curl ruby

对于基于RPM的系统:

yum install git curl ruby

现在用git工具把Betty库clone到你自定义的任何路径。这里我克隆到我的home目录,例如 /home/sk/.

git clone https://github.com/pickhardt/betty

添加betty的别名到你的bashrc配置文件。

sudo nano ~/.bashrc

将下列行添加到文件的末尾:

alias betty="/home/sk/betty/main.rb"

确保你已经正确地设置好了betty的路径。

好了,现在是时候和betty好好地玩耍了。

用法

你应该在英语短语之前加上单词“betty” [LCTT译注,你自然可以用你的小甜心的名字来替换这个不是知道是谁的Betty :>]。你也许已经知道,如果我们想知道在系统中我们的用户名,应该运行下面的命令:

whoami

输出是这样的:

sk

如你所见,我当前登录的用户名是 sk. 现在我也可以通过下面的betty命令获取相同的结果。

betty whats my username

输出是这样的:

Betty: Running whoami
sk

真的好酷,是不是?Betty理解我输入的“whats my username”短语,然后运行“whoami”命令,最后输出结果。

让我们也来看其他命令。

如果你的输入不够准确,Betty也能以多种方式回应你。例如,我们运行下面的命令:

betty whats my name

Betty不确定她应该查找系统用户名还是用户全名。这种情况下,她会询问你多个问题来找到准确的结果。如你下面所见,Betty问我想要运行哪一条命令(whoami 还是 finger $(whoami) | sed 's/.://;q')[LCTT译注,需要你的系统已经安装finger]。我只想知道我的用户名,所以我选择数字1

Betty: Okay, I have multiple ways to respond.
Betty: Enter the number of the command you want me to run, or N (no) if you don't want me to run any.
[1] whoami
Gets your system username.
[2] finger $(whoami) | sed 's/.*: *//;q'
Gets your full name.
1
Betty: Running whoami
sk

压缩和解压缩文件夹

如果你想要压缩一个文件或者文件夹,用下面的命令。例如,我想压缩我home目录下的“test”文件夹。

betty compress test/ test.tar.gz

输出是这样的:

Betty: Running tar -czvf test.tar.gz test/
test/
test/home/
test/home/sk/
test/home/sk/test/
test/home/sk/test/sample

类似的,我们可以用下面的命令来解压缩一个归档文件。

betty uncompress test.tar.gz

输出是这样的:

Betty: Running mkdir test &&  tar -zxvf test.tar.gz -C test
test/
test/home/
test/home/sk/
test/home/sk/test/
test/home/sk/test/sample

完整的Betty命令行列表

Betty工具有一些命令格式。如果你输入“what is my user name”而不是“whats my username”,它是不能识别的。所以,你只能输入Betty支持的英语短语。

下面给出一个Betty支持的完整的命令行列表。

Count:
betty how many words are in this directory
betty how many characters are in myfile.py
betty count lines in this folder
(Note that there's many ways to say more or less the same thing.)

Config:
betty change your name to Joe
betty speak to me
betty stop speaking to me

Datetime:
betty what time is it
betty what is todays date
betty what month is it
betty whats today

Find:
betty find me all files that contain california

Internet:
betty download http://www.mysite.com/something.tar.gz to something.tar.gz
betty uncompress something.tar.gz
betty unarchive something.tar.gz to somedir
(You can use unzip, unarchive, untar, uncompress, and expand interchangeably.)
betty compress /path/to/dir

iTunes:
betty mute itunes
betty unmute itunes
betty pause the music
betty resume itunes
betty stop my music
betty next song
betty prev track
betty what song is playing
(Note that the words song, track, music, etc. are interchangeable)

Fun:
betty go crazy
betty whats the meaning of life
...and more that are left for you to discover!

Map:
betty show me a map of mountain view

Meta:
betty what version are you (or just betty version)
betty whats your github again

Permissions:
betty give me permission to this directory
betty give anotheruser ownership of myfile.txt

Process:
betty show me all processes by root containing grep
betty show me all my processes containing netbio

Sizes:
betty show size for myfile.txt

Spotify:
betty play spotify
betty pause spotify
betty next spotify
betty previous spotify

User:
betty whats my username
betty whats my real name
betty whats my ip address
betty who else is logged in
betty whats my version of ruby

Web queries:
betty turn web on
betty please tell me what is the weather like in London

对Linux初级使用者来说,Betty似乎是一个非常nice的工具。希望这个工具对你也会非常有用。

Cheers!

源代码:


via: http://www.unixmen.com/betty-translate-english-phrases-linux-commands/

译者:love_daisy_love 校对:wxy

本文由 LCTT 原创翻译,Linux中国 荣誉推出



最新评论

[1]
koolar 发表于 2014-09-03 15:18 的评论:
好玩,一般不用吧?
linux 2014-09-03 15:55 1 回复
我觉得对于非英语国家,也就是看看,对于英语国家,顶多也是个有趣的东西。实用性不行。
[1]
love_daisy_love 发表于 2014-07-24 13:49 的评论:
标题校的不错哦
ReiNoir 2014-07-28 14:10 1 回复
不错+1
[1]
love_daisy_love 发表于 2014-07-24 13:49 的评论:
标题校的不错哦
linux 2014-07-24 20:14 1 回复
哈,其实觉得应该更标题党一些,可惜只能想到这个地步了。:》
游客 2014-07-24 17:30 1 回复
多此一举
[1]
石板印刷术 发表于 2014-07-24 09:46 的评论:
感觉 记忆betty的短语还不如直接记命令呢, 不过如果支持自然语言多并且好的话这是一种趋势
linux 2014-07-24 10:24 1 回复
其实我觉得更多是好玩,实用价值不大。
微博评论 2014-07-24 08:33 2 回复
//@Linux中国:嗯,所以要支持中文,甚至支持语音,也都可以考虑实现啊。//@yongsun: 有点意思,简单看了一下,没有用很高深的自然语言处理,只是用正则表达式来匹配关键字,然后进行候选命令的筛选…
微博评论 2014-07-23 23:03 3 回复
@LeBronJames_MH 可以玩玩
微博评论 2014-07-23 23:03 4 回复
哇哦!未来的自然语言甚至语音操作系统必须出现在封装了大量命令行的Linux系统啊!!!如果是传说中强大的以人的神经网络控制的操作系统呢?嘎嘎,再实现空气屏幕,完全是一个充满传奇的世界呀,绝对不科幻!my god,好吧,我的联想太宽了,估计是苦于对Linux那些繁琐但还算好玩的命令的期冀了……
微博评论 2014-07-23 22:33 3 回复
嗯,所以要支持中文,甚至支持语音,也都可以考虑实现啊。//@yongsun: 有点意思,简单看了一下,没有用很高深的自然语言处理,只是用正则表达式来匹配关键字,然后进行候选命令的筛选…
[1]
Vito 发表于 2014-07-23 19:45 的评论:
速度慢,玩了一次就不想玩了
linux 2014-07-23 22:27 1 回复
哈哈,只是新奇而已
7th 2014-07-23 20:47 1 回复
挺有意思的。不过还是习惯man看一下帮助。。。。
游客 2014-07-23 16:35 1 回复
为何我的报很多错
微博评论 2014-07-23 16:33 1 回复
有点意思,简单看了一下,没有用很高深的自然语言处理,只是用正则表达式来匹配关键字,然后进行候选命令的筛选…
wuanshou 2014-07-23 16:28 2 回复
有点儿意思。
微博评论 2014-07-23 16:03 2 回复
mark
LCTT 译者
Rekii 🌟🌟
共计翻译: 7.0 篇 | 共计贡献: 122
贡献时间:2014-05-18 -> 2014-09-17
访问我的 LCTT 主页 | 在 GitHub 上关注我


返回顶部

分享到微信

打开微信,点击顶部的“╋”,
使用“扫一扫”将网页分享至微信。