Yoda:您的 Linux 系统命令行个人助理
今天,我偶然发现了一个类似个人助理的实用程序,叫做 “Yoda”。Yoda 是一个命令行个人助理,可以帮助您在 Linux 中完成一些琐碎的任务。它是用 Python 编写的一个自由开源应用程序。在本指南中,我们将了解如何在 GNU/Linux 中安装和使用 Yoda。
安装 Yoda,命令行私人助理。
Yoda 需要 Python 2 和 PIP 。如果在您的 Linux 中没有安装 PIP,请参考下面的指南来安装它。只要确保已经安装了 python2-pip 。Yoda 可能不支持 Python 3。
注意:我建议你在 Python 虚拟环境下试用 Yoda。 不仅仅是 Yoda,应该总在虚拟环境中尝试任何 Python 应用程序,让它们不会干扰全局安装的软件包。 您可以按照上文链接中标题为“创建虚拟环境”一节中所述设置虚拟环境。
在您的系统上安装了 pip
之后,使用下面的命令克隆 Yoda 库。
<span class="pln">$ </span><span class="kwd">git</span><span class="kwd">clone</span><span class="pln"> https</span><span class="pun">:</span><span class="com">//github.com/yoda-pa/yoda</span>
上面的命令将在当前工作目录中创建一个名为 yoda
的目录,并在其中克隆所有内容。转到 yoda
目录:
<span class="pln">$ </span><span class="kwd">cd</span><span class="pln"> yoda</span><span class="pun">/</span>
运行以下命令安装 Yoda 应用程序。
<span class="pln">$ pip install </span><span class="pun">.</span>
请注意最后的点(.
)。 现在,所有必需的软件包将被下载并安装。
配置 Yoda
首先,设置配置以将您的信息保存在本地系统上。
运行下面的命令:
<span class="pln">$ yoda setup </span><span class="kwd">new</span>
填写下列的问题:
<span class="typ">Enter</span><span class="pln"> your name</span><span class="pun">:</span>
<span class="typ">Senthil</span><span class="typ">Kumar</span>
<span class="typ">What</span><span class="str">'s your email id?</span>
<span class="str">[email protected]</span>
<span class="str">What'</span><span class="pln">s your github username</span><span class="pun">?</span>
<span class="pln">sk</span>
<span class="typ">Enter</span><span class="pln"> your github password</span><span class="pun">:</span>
<span class="typ">Password</span><span class="pun">:</span>
<span class="typ">Where</span><span class="pln"> shall your config be stored</span><span class="pun">?</span><span class="pun">(</span><span class="typ">Default</span><span class="pun">:</span><span class="pun">~</span><span class="str">/.yoda/</span><span class="pun">)</span>
<span class="pln">A configuration </span><span class="kwd">file</span><span class="pln"> already exists</span><span class="pun">.</span><span class="typ">Are</span><span class="pln"> you sure you want to overwrite it</span><span class="pun">?</span><span class="pun">(</span><span class="pln">y</span><span class="pun">/</span><span class="pln">n</span><span class="pun">)</span>
<span class="pln">y</span>
你的密码在加密后保存在配置文件中,所以不用担心。
要检查当前配置,请运行:
<span class="pln">$ yoda setup check</span>
你会看到如下的输出。
<span class="typ">Name</span><span class="pun">:</span><span class="typ">Senthil</span><span class="typ">Kumar</span>
<span class="typ">Email</span><span class="pun">:</span><span class="pln"> sk@senthilkumar</span><span class="pun">.</span><span class="pln">com</span>
<span class="typ">Github</span><span class="pln"> username</span><span class="pun">:</span><span class="pln"> sk</span>
默认情况下,您的信息存储在 ~/.yoda
目录中。
要删除现有配置,请执行以下操作:
<span class="pln">$ yoda setup </span><span class="kwd">delete</span>
用法
Yoda 包含一个简单的聊天机器人。您可以使用下面的聊天命令与它交互。
<span class="pln">$ yoda chat </span><span class="kwd">who</span><span class="pln"> are you</span>
样例输出:
<span class="typ">Yoda</span><span class="pln"> speaks</span><span class="pun">:</span>
<span class="pln">I</span><span class="str">'m a virtual agent</span>
<span class="str">$ yoda chat how are you</span>
<span class="str">Yoda speaks:</span>
<span class="str">I'</span><span class="pln">m doing very well</span><span class="pun">.</span><span class="typ">Thanks</span><span class="pun">!</span>
以下是我们可以用 Yoda 做的事情:
测试网络速度
让我们问一下 Yoda 关于互联网速度的问题。运行:
<span class="pln">$ yoda speedtest</span>
<span class="typ">Speed</span><span class="kwd">test</span><span class="pln"> results</span><span class="pun">:</span>
<span class="typ">Ping</span><span class="pun">:</span><span class="lit">108.45</span><span class="pln"> ms</span>
<span class="typ">Download</span><span class="pun">:</span><span class="lit">0.75</span><span class="typ">Mb</span><span class="pun">/</span><span class="pln">s</span>
<span class="typ">Upload</span><span class="pun">:</span><span class="lit">1.95</span><span class="typ">Mb</span><span class="pun">/</span><span class="pln">s</span>
缩短和展开网址
Yoda 还有助于缩短任何网址:
<span class="pln">$ yoda url shorten https</span><span class="pun">:</span><span class="com">//www.ostechnix.com/</span>
<span class="typ">Here</span><span class="str">'s your shortened URL:</span>
<span class="str">https://goo.gl/hVW6U0</span>
要展开缩短的网址:
<span class="pln">$ yoda url </span><span class="kwd">expand</span><span class="pln"> https</span><span class="pun">:</span><span class="com">//goo.gl/hVW6U0</span>
<span class="typ">Here</span><span class="str">'s your original URL:</span>
<span class="str">https://www.ostechnix.com/</span>
阅读 Hacker News
我是 Hacker News 网站的常客。 如果你像我一样,你可以使用 Yoda 从下面的 Hacker News 网站阅读新闻。
<span class="pln">$ yoda hackernews</span>
<span class="typ">News</span><span class="pun">--</span><span class="lit">1</span><span class="pun">/</span><span class="lit">513</span>
<span class="typ">Title</span><span class="pun">--</span><span class="typ">Show</span><span class="pln"> HN</span><span class="pun">:</span><span class="pln"> a </span><span class="typ">Yelp</span><span class="kwd">for</span><span class="pln"> iOS developers</span>
<span class="typ">Description</span><span class="pun">--</span><span class="pln"> I came up </span><span class="kwd">with</span><span class="kwd">this</span><span class="pln"> idea </span><span class="str">"a Yelp for developers"</span><span class="kwd">when</span><span class="pln"> talking </span><span class="kwd">with</span><span class="kwd">my</span><span class="pln"> colleagues</span><span class="pun">.</span><span class="typ">My</span><span class="pln"> hypothesis </span><span class="kwd">is</span><span class="pln"> that</span><span class="pun">,</span><span class="pln"> it would be very helpful </span><span class="kwd">if</span><span class="pln"> we know </span><span class="kwd">more</span><span class="pln"> about a library before choosing to </span><span class="kwd">use</span><span class="pln"> it</span><span class="pun">.</span><span class="typ">It</span><span class="str">'s similar to that we want to know more about a restaurant by checki…</span>
<span class="str">url-- https://news.ycombinator.com/item?id=16636071</span>
<span class="str">Continue? [press-"y"]</span>
Yoda 将一次显示一个项目。 要阅读下一条新闻,只需输入 y
并按下回车。
管理个人日记
我们也可以保留个人日记以记录重要事件。
使用命令创建一个新的日记:
<span class="pln">$ yoda diary nn</span>
<span class="typ">Input</span><span class="pln"> your entry </span><span class="kwd">for</span><span class="pln"> note</span><span class="pun">:</span>
<span class="typ">Today</span><span class="pln"> I learned about </span><span class="typ">Yoda</span>
要创建新笔记,请再次运行上述命令。
查看所有笔记:
<span class="pln">$ yoda diary notes</span>
<span class="typ">Today</span><span class="str">'s notes:</span>
<span class="str">----------------</span>
<span class="str">Time | Note</span>
<span class="str">--------|-----</span>
<span class="str">16:41:41| Today I learned about Yoda</span>
不仅仅是笔记,Yoda 还可以帮助你创建任务。
要创建新任务,请���行:
<span class="pln">$ yoda diary nt</span>
<span class="typ">Input</span><span class="pln"> your entry </span><span class="kwd">for</span><span class="pln"> task</span><span class="pun">:</span>
<span class="typ">Write</span><span class="pln"> an article about </span><span class="typ">Yoda</span><span class="kwd">and</span><span class="pln"> publish it on </span><span class="typ">OSTechNix</span>
要查看任务列表,请运行:
<span class="pln">$ yoda diary tasks</span>
<span class="typ">Today</span><span class="str">'s agenda:</span>
<span class="str">----------------</span>
<span class="str">Status | Time | Text</span>
<span class="str">-------|---------|-----</span>
<span class="str">O | 16:44:03: Write an article about Yoda and publish it on OSTechNix</span>
<span class="str">----------------</span>
<span class="str">Summary:</span>
<span class="str">----------------</span>
<span class="str">Incomplete tasks: 1</span>
<span class="str">Completed tasks: 0</span>
正如你在上面看到的,我有一个未完成的任务。 要将其标记为已完成,请运行以下命令并输入已完成的任务序列号并按下回车键:
<span class="pln">$ yoda diary ct</span>
<span class="typ">Today</span><span class="str">'s agenda:</span>
<span class="str">----------------</span>
<span class="str">Number | Time | Task</span>
<span class="str">-------|---------|-----</span>
<span class="str">1 | 16:44:03: Write an article about Yoda and publish it on OSTechNix</span>
<span class="str">Enter the task number that you would like to set as completed</span>
<span class="str">1</span>
您可以随时使用命令分析当前月份的任务:
<span class="pln">$ yoda diary analyze</span>
<span class="typ">Percentage</span><span class="pln"> of incomplete task </span><span class="pun">:</span><span class="lit">0</span>
<span class="typ">Percentage</span><span class="pln"> of complete task </span><span class="pun">:</span><span class="lit">100</span>
<span class="typ">Frequency</span><span class="pln"> of adding task </span><span class="pun">(</span><span class="typ">Task</span><span class="pun">/</span><span class="typ">Day</span><span class="pun">)</span><span class="pun">:</span><span class="lit">3</span>
有时候,你可能想要记录一个关于你爱的或者敬佩的人的个人资料。
记录关于爱人的笔记
首先,您需要设置配置来存储朋友的详细信息。 请运行:
<span class="pln">$ yoda love setup</span>
输入你的朋友的详细信息:
<span class="typ">Enter</span><span class="pln"> their name</span><span class="pun">:</span>
<span class="typ">Abdul</span><span class="typ">Kalam</span>
<span class="typ">Enter</span><span class="pln"> sex</span><span class="pun">(</span><span class="pln">M</span><span class="pun">/</span><span class="pln">F</span><span class="pun">):</span>
<span class="pln">M</span>
<span class="typ">Where</span><span class="kwd">do</span><span class="pln"> they live</span><span class="pun">?</span>
<span class="typ">Rameswaram</span>
要查看此人的详细信息,请运行:
<span class="pln">$ yoda love status</span>
<span class="pun">{</span><span class="str">'place'</span><span class="pun">:</span><span class="str">'Rameswaram'</span><span class="pun">,</span><span class="str">'name'</span><span class="pun">:</span><span class="str">'Abdul Kalam'</span><span class="pun">,</span><span class="str">'sex'</span><span class="pun">:</span><span class="str">'M'</span><span class="pun">}</span>
要添加你的爱人的生日:
<span class="pln">$ yoda love addbirth</span>
<span class="typ">Enter</span><span class="pln"> birthday</span>
<span class="lit">15</span><span class="pun">-</span><span class="lit">10</span><span class="pun">-</span><span class="lit">1931</span>
查看生日:
<span class="pln">$ yoda love showbirth</span>
<span class="typ">Birthday</span><span class="kwd">is</span><span class="lit">15</span><span class="pun">-</span><span class="lit">10</span><span class="pun">-</span><span class="lit">1931</span>
你甚至可以添加关于该人的笔记:
<span class="pln">$ yoda love note</span>
<span class="typ">Avul</span><span class="typ">Pakir</span><span class="typ">Jainulabdeen</span><span class="typ">Abdul</span><span class="typ">Kalam</span><span class="pln"> better known </span><span class="kwd">as</span><span class="pln"> A</span><span class="pun">.</span><span class="pln"> P</span><span class="pun">.</span><span class="pln"> J</span><span class="pun">.</span><span class="typ">Abdul</span><span class="typ">Kalam</span><span class="pun">,</span><span class="pln"> was the </span><span class="lit">11th</span><span class="typ">President</span><span class="pln"> of </span><span class="typ">India</span><span class="kwd">from</span><span class="lit">2002</span><span class="pln"> to </span><span class="lit">2007.</span>
您可以使用命令查看笔记:
<span class="pln">$ yoda love notes</span>
<span class="typ">Notes</span><span class="pun">:</span>
<span class="lit">1</span><span class="pun">:</span><span class="typ">Avul</span><span class="typ">Pakir</span><span class="typ">Jainulabdeen</span><span class="typ">Abdul</span><span class="typ">Kalam</span><span class="pln"> better known </span><span class="kwd">as</span><span class="pln"> A</span><span class="pun">.</span><span class="pln"> P</span><span class="pun">.</span><span class="pln"> J</span><span class="pun">.</span><span class="typ">Abdul</span><span class="typ">Kalam</span><span class="pun">,</span><span class="pln"> was the </span><span class="lit">11th</span><span class="typ">President</span><span class="pln"> of </span><span class="typ">India</span><span class="kwd">from</span><span class="lit">2002</span><span class="pln"> to </span><span class="lit">2007.</span>
你也可以写下这个人喜欢的东西:
<span class="pln">$ yoda love like</span>
<span class="typ">Add</span><span class="pln"> things they like</span>
<span class="typ">Physics</span><span class="pun">,</span><span class="typ">Aerospace</span>
<span class="typ">Want</span><span class="pln"> to add </span><span class="kwd">more</span><span class="pln"> things they like</span><span class="pun">?</span><span class="pun">[</span><span class="pln">y</span><span class="pun">/</span><span class="pln">n</span><span class="pun">]</span>
<span class="pln">n</span>
要查看他们喜欢的东西,请运行:
<span class="pln">$ yoda love likes</span>
<span class="typ">Likes</span><span class="pun">:</span>
<span class="lit">1</span><span class="pun">:</span><span class="typ">Physics</span><span class="pun">,</span><span class="typ">Aerospace</span>
跟踪资金费用
您不需要单独的工具来维护您的财务支出。 Yoda 会替您处理好。
首先,使用命令设置您的金钱支出配置:
<span class="pln">$ yoda money setup</span>
输入您的货币代码和初始金额:
<span class="typ">Enter</span><span class="kwd">default</span><span class="pln"> currency code</span><span class="pun">:</span>
<span class="pln">INR</span>
<span class="pun">{</span><span class="pln">u</span><span class="str">'USD'</span><span class="pun">:</span><span class="lit">0.015338</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'IDR'</span><span class="pun">:</span><span class="lit">211.06</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'BGN'</span><span class="pun">:</span><span class="lit">0.024436</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'ISK'</span><span class="pun">:</span><span class="lit">1.5305</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'ILS'</span><span class="pun">:</span><span class="lit">0.053402</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'GBP'</span><span class="pun">:</span><span class="lit">0.010959</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'DKK'</span><span class="pun">:</span><span class="lit">0.093063</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'CAD'</span><span class="pun">:</span><span class="lit">0.020041</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'MXN'</span><span class="pun">:</span><span class="lit">0.28748</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'HUF'</span><span class="pun">:</span><span class="lit">3.8873</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'RON'</span><span class="pun">:</span><span class="lit">0.058302</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'MYR'</span><span class="pun">:</span><span class="lit">0.060086</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'SEK'</span><span class="pun">:</span><span class="lit">0.12564</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'SGD'</span><span class="pun">:</span><span class="lit">0.020208</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'HKD'</span><span class="pun">:</span><span class="lit">0.12031</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'AUD'</span><span class="pun">:</span><span class="lit">0.019908</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'CHF'</span><span class="pun">:</span><span class="lit">0.014644</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'KRW'</span><span class="pun">:</span><span class="lit">16.429</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'CNY'</span><span class="pun">:</span><span class="lit">0.097135</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'TRY'</span><span class="pun">:</span><span class="lit">0.06027</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'HRK'</span><span class="pun">:</span><span class="lit">0.092986</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'NZD'</span><span class="pun">:</span><span class="lit">0.021289</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'THB'</span><span class="pun">:</span><span class="lit">0.47854</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'EUR'</span><span class="pun">:</span><span class="lit">0.012494</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'NOK'</span><span class="pun">:</span><span class="lit">0.11852</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'RUB'</span><span class="pun">:</span><span class="lit">0.88518</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'JPY'</span><span class="pun">:</span><span class="lit">1.6332</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'CZK'</span><span class="pun">:</span><span class="lit">0.31764</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'BRL'</span><span class="pun">:</span><span class="lit">0.050489</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'PLN'</span><span class="pun">:</span><span class="lit">0.052822</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'PHP'</span><span class="pun">:</span><span class="lit">0.79871</span><span class="pun">,</span><span class="pln"> u</span><span class="str">'ZAR'</span><span class="pun">:</span><span class="lit">0.1834</span><span class="pun">}</span>
<span class="pun">₹</span>
<span class="typ">Indian</span><span class="pln"> rupee</span>
<span class="typ">Enter</span><span class="pln"> initial amount</span><span class="pun">:</span>
<span class="lit">10000</span>
要查看金钱配置,只需运行:
<span class="pln">$ yoda money status</span>
<span class="pun">{</span><span class="str">'initial_money'</span><span class="pun">:</span><span class="lit">10000</span><span class="pun">,</span><span class="str">'currency_code'</span><span class="pun">:</span><span class="str">'INR'</span><span class="pun">}</span>
让我们假设你买了一本价值 250 卢比的书。 要添加此费用,请运行:
<span class="pln">$ yoda money exp</span>
<span class="typ">Spend</span><span class="lit">250</span><span class="pln"> INR on books</span>
<span class="pln">output</span><span class="pun">:</span>
要查看花费,请运行:
<span class="pln">$ yoda money exps</span>
<span class="lit">2018</span><span class="pun">-</span><span class="lit">03</span><span class="pun">-</span><span class="lit">21</span><span class="lit">17</span><span class="pun">:</span><span class="lit">12</span><span class="pun">:</span><span class="lit">31</span><span class="pln"> INR </span><span class="lit">250</span><span class="pln"> books</span>
创建想法列表
创建一个新的想法:
<span class="pln">$ yoda ideas add </span><span class="pun">--</span><span class="pln">task </span><span class="pun"><</span><span class="pln">task_name</span><span class="pun">></span><span class="pun">--</span><span class="pln">inside </span><span class="pun"><</span><span class="pln">project_name</span><span class="pun">></span>
列出想法:
<span class="pln">$ yoda ideas show</span>
从任务中移除一个想法:
<span class="pln">$ yoda ideas remove </span><span class="pun">--</span><span class="pln">task </span><span class="pun"><</span><span class="pln">task_name</span><span class="pun">></span><span class="pun">--</span><span class="pln">inside </span><span class="pun"><</span><span class="pln">project_name</span><span class="pun">></span>
要完全删除这个想法,请运行:
<span class="pln">$ yoda ideas remove </span><span class="pun">--</span><span class="pln">project </span><span class="pun"><</span><span class="pln">project_name</span><span class="pun">></span>
学习英语词汇
Yoda 帮助你学习随机英语单词并追踪你的学习进度。
要学习一个新单词,请输入:
<span class="pln">$ yoda vocabulary word</span>
它会随机显示一个单词。 按回车键显示单词的含义。 再一次,Yoda 问你是否已经知道这个词的意思。 如果您已经知道,请输入“是”。 如果您不知道,请输入“否”。 这可以帮助你跟踪你的进度。 使用以下命令来了解您的进度。
<span class="pln">$ yoda vocabulary accuracy</span>
此外,Yoda 可以帮助您做其他一些事情,比如找到单词的定义和创建插卡以轻松学习任何内容。 有关更多详细信息和可用选项列表,请参阅帮助部分。
<span class="pln">$ yoda </span><span class="pun">--</span><span class="pln">help</span>
更多好的东西来了。请继续关注!
干杯!
via:ostechnix