Linux中國

Betty:和你的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中國 榮譽推出


本文轉載來自 Linux 中國: https://github.com/Linux-CN/archive

對這篇文章感覺如何?

太棒了
0
不錯
0
愛死了
0
不太好
0
感覺很糟
0
雨落清風。心向陽

    You may also like

    Leave a reply

    您的郵箱地址不會被公開。 必填項已用 * 標註

    這個站點使用 Akismet 來減少垃圾評論。了解你的評論數據如何被處理

    More in:Linux中國

    Linux中國

    關於Linux防火牆iptables的面試問答

    Nishita Agarwal是Tecmint的用戶,她將分享關於她剛剛經歷的一家公司(印度的一家私人公司Pune)的面試經驗。在面試中她被問及許多不同的問題,但她是iptables方面的專家,因此她想分享這些關於iptables的問題和相應的答案給那些以後可能會進行相關面試的人。 所有的問題和相應的答案都基於Nishita Agarwal的記憶並經過了重寫。 嗨,朋友!我叫Nishita Agarwal。我已經取得了理學學士學位,我的專業集中在UNIX和它的變種(BSD,Linux)。它們一直深深的吸引著我。我在存儲方面有1年多的經驗。我正在尋求職業上的變化,並將供職於印度的P
    Linux中國

    Lets Encrypt 已被所有主流瀏覽器所信任

    旨在讓每個網站都能使用 HTTPS 加密的非贏利組織 Lets Encrypt 已經得了 IdenTrust的交叉簽名,這意味著其證書現在已經可以被所有主流的瀏覽器所信任。從這個裡程碑事件開始,訪問者訪問使用了Lets Encrypt 證書的網站不再需要特別配置就可以得到 HTTPS 安全保護了。 Lets Encrypt 的兩個中級證書 ...
    Linux中國

    SSL/TLS 加密新紀元 – Lets Encrypt

    根據 Let's Encrypt 官方博客消息,Let's Encrypt 服務將在下周(11 月 16 日)正式對外開放。 Let's Encrypt 項目是由互聯網安全研究小組(ISRG,Internet Security Research Group)主導並開發的一個新型數字證書認證機構(CA,Certificate ...