pickhardt / betty Goto Github PK
View Code? Open in Web Editor NEWFriendly English-like interface for your command line. Don't remember a command? Ask Betty.
Friendly English-like interface for your command line. Don't remember a command? Ask Betty.
She used to:
$ betty abracadabra
Betty: Sorry, I don't know how to abracadabra yet. If you are a developer you can teach me!
I do know how to
Betty: Control Spotify
Betty: Count
Betty: Show information related to your User accounts
Betty: Download files from Internet, uncompress/compress them
Betty: Find files
Betty: Manipulate a running Procs (processes)
Betty: Control iTunes
Betty: Pull out Maps from Google
Betty: Find file Sizes
Betty: Show OS name
Betty: Manage file Permissions
Betty: Show information about Datetime
Betty: Translate
but now she:
$ betty abracadabra
Betty: I don't understand. Hopefully someone will make a pull request so that one day I will understand.
This is somewhat similar to this issue. It would be extra cool if users could configure Betty to use a different name. For example, I might want to use "Alfred" (like from Batman), "Jarvis" (from Ironman), or "Watson " (from Sherlock Holmes), or to go extra geeky, "Computer" (like in Star Trek).
How Should I put it in fish, given that fish uses functions instead?
IMHO, if someone is serious about this then eventually there would be a need to use things like Stanford NLP or OpenNLP toolkits. Have a look at Treat also - https://github.com/louismullie/treat
We would have to move out from regex domain and into the real world of conversations pretty soon to handle growing number of permutations and combinations in inputs. I think it would be a good effort to have someone assigned to design basic tests for using NLP with betty
I am not ruby dev, so listen my idea:
How to get Betty more siri?
Let`s use google power.
On command "what is my name" Betty performs google search request like:
what is my name pickhardt AND " betty / lib /" site:github.com filetype:rb
As result will be url/urls to module(s) where such phrase possible affects.
File will be simple text file with commands annotated by groups of key words. Next Betty just parse key verb and execute command.
File example:
#name,my //It is common keywords
##user //target keyword(s)
whoami
##full,surname,first
finger $(whoami) | sed 's/.*: *//;q'
##where, directory
pwd
If query points common keywords only, executes first command.
In my example betty will executw whoami command.
So it will be wery easy to write modules.
It'd be nice to have betty mount /proc, /dev, /dev/pts and /sys, inside a directory, and then chroot into that directory. I have a shell script that does this right now:
#!/bin/fish
function properchroot
if [ (count $argv) -ne 1 ]
echo "Usage: properchroot /path/to/chrootable/environment"
exit
end
mount -o bind /proc $argv[1]/proc
mount -o bind /dev $argv[1]/dev
mount -o bind /dev/pts $argv[1]/dev/pts
mount -o bind /sys $argv[1]/sys
chroot $argv[1]
end
Could this be done automatically when when asks "betty [virtualize | chroot [into]] DIRECTORY?
$ betty
/Users/chris/.Misc/betty/main.rb:6:in `require': /Users/chris/.Misc/betty/lib/process.rb:30: undefined (?...) sequence: / (SyntaxError)
(?# todo <kill>kill\s)
(show|find|give|me|a|list|of|those|\s)*
(?<all>all\s)?
(?<my>my\s)?
PROCESS(es)?
(with|for|process|\s)* (id\s(?<process_id>[0-9]+))?
(for|with|by\s)* (user\s(?<user_id>\w+))?
((like|matching|with|pattern|containing|that|which|contain|\s)+ (?<pattern>\w+))?
/
from /Users/chris/.Misc/betty/main.rb:6
from /Users/chris/.Misc/betty/main.rb:6:in `each'
from /Users/chris/.Misc/betty/main.rb:6
I just installed Betty and tried to use it to install the program called Processing, but it didn't work. It always runs the 'ps' command when I try to manipulate files and folders called 'processing.' Example:
betty move processing-2.2/ to ~/Processing
runs the 'ps' command instead of moving that folder.
betty
tries to save it's configuration globaly even if I'm not root, and, for course, it fails:
$ betty speak to me
/usr/lib/betty/config.rb:33:in `initialize': Permission denied @ rb_sysopen - /etc/betty/bettyconfig (Errno::EACCES)
from /usr/lib/betty/config.rb:33:in `open'
from /usr/lib/betty/config.rb:33:in `save'
from /usr/lib/betty/config.rb:25:in `set'
from /usr/lib/betty/config.rb:42:in `block in interpret'
from /usr/bin/betty:89:in `call'
from /usr/bin/betty:89:in `run'
from /usr/bin/betty:202:in `main'
from /usr/bin/betty:223:in `<main>'
$XDG_CONFIG_DIR should be used if UID != 0.
As it is right now, betty
uses the imperial system by default (for things like, say, the weather).
This makes these answers understandable for only three countries in the world, while people from the other 193 will just stare confused, being unable to interpret these results.
Since betty can't convert between units either (#89), this make these results even more useless.
Betty should have an option to use the SI, or, at the very least, use it by default.
I've upgraded to Betty 1.6 and the new calculations feature doesn't work:
$ betty what is 40 plus 2
Betty: Running bc <<< 40+2
sh: 1: Syntax error: redirection unexpected
However, if I type the command that Betty is supposed to run, it works:
bc <<< 40+2
42
I'm using Ubuntu 14.04 / bash 4.3 / ruby 1.9.3.4.
Hi there,
I've been testing out betty recently. When I ask betty to run something it needs few cli utilities for getting that information.
I was wondering, is in development pipeline to automatically generate dependency graphs for querying that information and installing the necessary tools for that, with user permission. maybe?
What happens now, is something like this:
○ → betty whats my real name
Betty: Running finger `whoami` | awk -F: '{ print $3 }' | head -n1 | sed 's/^ //'
sh: 1: finger: not found
Or,
○ → betty go crazy
Betty: Woah.
sh: 1: osascript: not found
sh: 1: osascript: not found
sh: 1: osascript: not found
...
This will help in developing advanced functionalities in the future which will need more than default packages.
:explanation => "Counts the total number of #{ what } in #{ is_this_directory ? 'all the files in the current directory, including subdirectories' : what }."
I think you meant """: where }.""".
The version number in the README.md (0.1.5) does not correspond to the releases/tags (0.1.4).
EXTENSION
is optional, so you could ask her for all filesI never remember how.
can we get tarring (not just untarring)?
betty gzip tar the dir_to_tar directory
The current way a users name is parsed can be streamlined from:
finger `whoami` | awk -F: '{ print $3 }' | head -n1 | sed 's/^ //'
With a single awk
call:
finger $(whoami) | awk -F': ' 'NR==1{print $3}'
Or a single sed
call:
finger $(whoami) | sed 's/.*: *//;q'
After cloning the repo and running ruby install.rb
in the betty directory I get the following:
install.rb:25: syntax error, unexpected ',', expecting '='
*junk, SHELL = `echo $SHELL`.split('/')
^
On master and dev updated branches
$ betty
/home/lpanebr/Applications/betty/main.rb:6:in `require': /home/lpanebr/Applications/betty/lib/process.rb:30: undefined (?...) sequence: / (SyntaxError)
(?# todo <kill>kill\s)
(show|find|give|me|a|list|of|those|\s)*
(?<all>all\s)?
(?<my>my\s)?
PROCESS(es)?
(with|for|process|\s)* (id\s(?<process_id>[0-9]+))?
(for|with|by\s)* (user\s(?<user_id>\w+))?
((like|matching|with|pattern|containing|that|which|contain|\s)+ (?<pattern>\w+))?
/
from /home/lpanebr/Applications/betty/main.rb:6
from /home/lpanebr/Applications/betty/main.rb:6:in `each'
from /home/lpanebr/Applications/betty/main.rb:6
It would be cool if when Betty didn't understand, and you tried again and got it right, Betty lets you automatically add an alternative matcher so she knows what you mean next time.
Also, if you can't get Betty to do what you want, it would be cool if she opened up your editor with the boilerplate to make a new command.
These learnings can be shared via github pull requests.
I'm running linux 2.6.18-238.el5 with ruby 2.1.0:
$ uname -s
Linux
$ uname -r
2.6.18-238.el5
ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
my changelog says I'm at version 0.1.5 from May 13, I can't ask Betty anything because I get this parse error every time:
betty -v
/betty/main.rb:126: parse error
say += " -v '#{BettyConfig.get("voice")}'" if BettyConfig.get("voice")
The translate does not work on ubuntu because the correct command would be xdg-open
instead of open
.
It would be great if the betty framework had a way of using OS-independent command. Those could be set-up on the config file.
Example on the translate.rb:
:command => "open https://translate.google.com/##{from}/#{to}/#{translate_string}",
What if we could:
:command => "#{OS-Command} https://translate.google.com/##{from}/#{to}/#{translate_string}",
For the future:
$ betty config <this-command>=<this>
betty whats the size of:
$ betty whats the size of ~/Dropbox
1.05 MB 1102408 /home/lpanebr/Dropbox
$ du -sch ~/Dropbox
1.1G /home/lpanebr/Dropbox
1.1G total
There's a small issue on sizes.rb
, it's calculating the sizes using binary multiples, but showing decimal prefixes (i.e. for 2^10 KB instead of KiB).
So basically the idea should be to choose either one or the other.
Is there an active fork of this project? It seems to popular to go inactive for so long.
I get the error below when trying to install betty:
~/betty already exists! Please manually remove if you want to proceed (RuntimeError)
I'm running elementary OS Built on Ubuntu 12.04 ( "Precise" ).
After installing according to the "manual instructions" offered, when issuing the command I get the following:
luis@epsilon:~$ betty whats my username
Module /home/luis/betty/lib/process.rb could not be loaded because of /home/luis/betty/lib/process.rb:31: undefined (?...) sequence: /
(show|find|give|me|a|list|of|those|\s)*
(?all\s)?
(?my\s)?
PROCESS(es)?
(with|which|that|\s)*
(for|process|\s)* (id\s(?<process_id>[0-9]+))?
(for|belonging|belong|to|by|\s)* (user\s(?<user_id>\w+))?
((like|matching|with|pattern|containing|that|which|contain|\s)+ (?\w+))?
/
Module /home/luis/betty/lib/convert.rb could not be loaded because of /home/luis/betty/lib/convert.rb:29: undefined (?...) sequence: /
(convert|save|transform)\s
(?all\s)?
(?my\s)?
(?.?)\s
(to|as)\s
(?.)
/
Module /home/luis/betty/lib/translate.rb could not be loaded because of /home/luis/betty/lib/translate.rb:13: odd number list for Hash
command: Command.browser("https://tran...
^
/home/luis/betty/lib/translate.rb:13: syntax error, unexpected ':', expecting '}'
command: Command.browser("https://tran...
^
/home/luis/betty/lib/translate.rb:13: syntax error, unexpected ',', expecting kEND
/home/luis/betty/lib/translate.rb:15: syntax error, unexpected '}', expecting kEND
/home/luis/betty/lib/translate.rb:24: odd number list for Hash
category: "Translate",
^
/home/luis/betty/lib/translate.rb:24: syntax error, unexpected ':', expecting '}'
category: "Translate",
^
/home/luis/betty/lib/translate.rb:24: syntax error, unexpected ',', expecting kEND
/home/luis/betty/lib/translate.rb:25: syntax error, unexpected ',', expecting kEND
/home/luis/betty/lib/translate.rb:27: syntax error, unexpected '}', expecting kEND
/home/luis/betty/lib/translate.rb:32: syntax error, unexpected $end, expecting kEND
Module /home/luis/betty/lib/calc.rb could not be loaded because of /home/luis/betty/lib/calc.rb:34: odd number list for Hash
command: "bc <<< #{arg1}#{op}#{arg2}",
^
/home/luis/betty/lib/calc.rb:34: syntax error, unexpected ':', expecting '}'
command: "bc <<< #{arg1}#{op}#{arg2}",
^
/home/luis/betty/lib/calc.rb:34: syntax error, unexpected ',', expecting kEND
/home/luis/betty/lib/calc.rb:36: syntax error, unexpected '}', expecting kEND
/home/luis/betty/lib/calc.rb:44: odd number list for Hash
category: "Calculate",
^
/home/luis/betty/lib/calc.rb:44: syntax error, unexpected ':', expecting '}'
category: "Calculate",
^
/home/luis/betty/lib/calc.rb:44: syntax error, unexpected ',', expecting kEND
/home/luis/betty/lib/calc.rb:45: syntax error, unexpected ',', expecting kEND
/home/luis/betty/lib/calc.rb:47: syntax error, unexpected '}', expecting kEND
/home/luis/betty/lib/calc.rb:52: syntax error, unexpected $end, expecting kEND
Betty: Running whoami
luis
I ran betty what version
and it printed:
/home/jan/bin/betty/lib/user.rb:51:in `interpret': undefined method `strip' for nil:NilClass (NoMethodError)
from /home/jan/bin/betty/main.rb:52:in `block in interpret'
from /home/jan/bin/betty/main.rb:51:in `each'
from /home/jan/bin/betty/main.rb:51:in `interpret'
from /home/jan/bin/betty/main.rb:225:in `main'
from /home/jan/bin/betty/main.rb:258:in `<main>'
(betty version
and betty what version are you
work fine)
Doesn't affect me, just wanted to report it.
In the readme:
She translates English-like phrases into commands in case you every run into situations like this.
Replace "every" with "ever." A small change that wasn't worth a PR.
"betty what is my os" gets me the name "Linux". Well, that's self-evident. What I'm more interested in is what distro and distro version I am running, like this:
> betty what is my os version (or distro)
Betty: Ubuntu 14.04 LTS (trusty)
For Linux, the command lsb_release can be used. I don't know what's available for OSX, but I can imagine that quickly finding out what kind of feline you're running on can sometimes be pretty useful, too.
Thanks for writing a very awesome tool, by the way. 👍
Hello,
Wherever i try to run a command, I get the correct answer but with a odd error message
Module /software/src/betty/lib/process.rb could not be loaded because of
The message is as is.
No clue about what's going on.
Do you have a hint or is someone else facing the same issue ?
Regards
If Betty can run following commands or it would be grate...
betty update system / betty run update --- > (apt-get update)
betty upgrade system --- > (apt-get upgrade)
betty dist-upgrade --- > (dist-upgrade)
betty install <package_name> --- > (apt-get install)
betty remove <package_name> --- > (apt-get remove)
In order to approach #57 in bite sized chunks, a good first step would be pulling in all the regular expression usage into the beginnings of a grammar.
This gem looks like it would be perfect for the task, check it out: http://semr.rubyforge.org/
If you don't feel like clicking a link here is one cool example...
require 'rubygems'
require 'semr'
language = Semr::Language.create do #also accepts a path to a file instead of a block
concept :number, any_number, :normalize => as_fixnum
concept :greeting, words('hi', 'goodbye', 'hello')
phrase 'say :greeting :number times' do |greeting, number|
number.to_i.times { puts greeting }
end
end
language.parse('say hello 6 times')
# hello
# hello
# hello
# hello
# hello
# hello
language.parse('say goodbye 2 times')
# goodbye
# goodbye
has anyone yet combined betty with a speech to text engine?
I'm really excited to be able to use Betty, but I'm having some problems. I installed via the instructions at webupd8 and am getting outputs like:
jason@work:$ betty what time is it?$
Module /home/jason/betty/lib/convert.rb could not be loaded because of /home/jason/betty/lib/convert.rb:29: undefined (?...) sequence: /
(convert|save|transform)\s
(?all\s)?
(?my\s)?
(?.?)\s
(to|as)\s
(?.)
/
Module /home/jason/betty/lib/process.rb could not be loaded because of /home/jason/betty/lib/process.rb:31: undefined (?...) sequence: /
(show|find|give|me|a|list|of|those|\s)*
(?all\s)?
(?my\s)?
PROCESS(es)?
(with|which|that|\s)*
(for|process|\s)* (id\s(?<process_id>[0-9]+))?
(for|belonging|belong|to|by|\s)* (user\s(?<user_id>\w+))?
((like|matching|with|pattern|containing|that|which|contain|\s)+ (?\w+))?
/
Module /home/jason/betty/lib/calc.rb could not be loaded because of /home/jason/betty/lib/calc.rb:34: odd number list for Hash
command: "bc <<< #{arg1}#{op}#{arg2}",
^
/home/jason/betty/lib/calc.rb:34: syntax error, unexpected ':', expecting '}'
command: "bc <<< #{arg1}#{op}#{arg2}",
^
/home/jason/betty/lib/calc.rb:34: syntax error, unexpected ',', expecting kEND
/home/jason/betty/lib/calc.rb:36: syntax error, unexpected '}', expecting kEND
/home/jason/betty/lib/calc.rb:44: odd number list for Hash
category: "Calculate",
^
/home/jason/betty/lib/calc.rb:44: syntax error, unexpected ':', expecting '}'
category: "Calculate",
^
/home/jason/betty/lib/calc.rb:44: syntax error, unexpected ',', expecting kEND
/home/jason/betty/lib/calc.rb:45: syntax error, unexpected ',', expecting kEND
/home/jason/betty/lib/calc.rb:47: syntax error, unexpected '}', expecting kEND
/home/jason/betty/lib/calc.rb:52: syntax error, unexpected $end, expecting kEND
Module /home/jason/betty/lib/translate.rb could not be loaded because of /home/jason/betty/lib/translate.rb:13: odd number list for Hash
command: Command.browser("https://tran...
^
/home/jason/betty/lib/translate.rb:13: syntax error, unexpected ':', expecting '}'
command: Command.browser("https://tran...
^
/home/jason/betty/lib/translate.rb:13: syntax error, unexpected ',', expecting kEND
/home/jason/betty/lib/translate.rb:15: syntax error, unexpected '}', expecting kEND
/home/jason/betty/lib/translate.rb:24: odd number list for Hash
category: "Translate",
^
/home/jason/betty/lib/translate.rb:24: syntax error, unexpected ':', expecting '}'
category: "Translate",
^
/home/jason/betty/lib/translate.rb:24: syntax error, unexpected ',', expecting kEND
/home/jason/betty/lib/translate.rb:25: syntax error, unexpected ',', expecting kEND
/home/jason/betty/lib/translate.rb:27: syntax error, unexpected '}', expecting kEND
/home/jason/betty/lib/translate.rb:32: syntax error, unexpected $end, expecting kEND
Betty: Running date +"%r (%T)"
10:59:08 AM (10:59:08)
jason@work:
So it does output the correct time, but also all the errors prior to that. I tried it with and without sudo, and it does the same thing in both terminator and terminal. I'm on Ubuntu 12.04 if that matters. I can add my .bashrc if that will help at all, is there anything I can do to troubleshoot this issue?
Thanks
Typing,
sudo betty make me a sandwich
yields:
Betty: Make your own damn sandwich.
Typing,
betty sudo make me a sandwich
yields:
Betty: Ha, like sudo has any effect on me!
Expected behaviour is for one of those two to yield:
Betty: Okay.
aniket [~] -> betty what is my name
/home/aniket/src/betty/main.rb:6:in `require': /home/aniket/src/betty/lib/itunes.rb:81: nested *?+ in regexp: /^what\'?s?\s+((songs?|musics?|tracks?|iTunes)\s+)?(is)?\s?+play(?:ing)?$/ (SyntaxError)
from /home/aniket/src/betty/main.rb:6
from /home/aniket/src/betty/main.rb:6:in `each'
from /home/aniket/src/betty/main.rb:6
Version:
aniket [~] -> irb -v
irb 0.9.5(05/04/13)
A nice feature would be commands like :
Or more advanced...
Something for the future maybe.
Betty could have a way for Modules to register an array of entry commands. Or she could do it by herself just by analyzing command.match
or the usage
array of each Module.
She would then register those as auto-complete command line possibilities.
$ betty s #hit tab
show size shuflle
$ betty s
Like this:
function genie(){
query=printf "%s+" $@
echo $query
result=curl -s "https://weannie.pannous.com/api?out=simple&input=$query"
echo $result
say $result 2>/dev/null
}
alias hey=genie
alias what="genie what"
alias when="genie when"
alias how="genie how"
me:~$ how old is obama
Barack Obama is 52 years old
And just for the kicks:
me:~$ what is the root of pi
It is approximately 1.7725
Is it a necessity that betty converts all requests to bash commands. What i mean by that is can i add functionality that does not necessarily converts to bash commands.
I am trying to add some commands of google now here, which are not really related to command line.
Hey.... I'm totally new to zsh, but i installed it the other day and it seems like it's based on bash. But this repo "Oh My Zsh" has tons of "plugins" that can work with it, which is really just a betty like CLI interface to lots of standard linux type stuff:
https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins
Maybe you could use their plugin format in betty to gets lots more commands pretty easy? Food for thought!
Here's an accessible article on this trend (?).
It's really off-putting. :(
Use ip addr
instead of ifconfig
ifconfig is obsolete.
and in Debian, ifconfig is in /sbin/, which needs superuser.
I was trying to add your tool to brew:
Homebrew/legacy-homebrew#29067
but they require a tarball and therefore a tag for their formulas.
Tim
By default the Mac OS X Terminal uses .bash_profile, not .bashrc. The installation script should concatenate to .bash_profile so that users don't have to change it manually.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.