Tourmaline
A configurable ruby interpreter for the command line
Setup
gem install tourmaline
Plugins
Tourmaline's functionality can be extended via ruby scripts (*.rb
files). Just place them inside the ~/.tourmaline/lib
folder.
As an example, create the file ~/.tourmaline/lib/plugin_file.rb
with the code:
def execute_plugin
puts "plugin executed!"
end
Given that, you will be able to run rb 'execute_plugin'
Examples
Show only the time of each ping:
ping www.google.com | rb 'lines.include?("time=").split("time=")[1].puts'
Sum the first three numbers:
echo -e '1\n5\n3\n7\n' | rb 'lines.take(3).to_i.inject(:+).puts'
Echo until "quit" is entered:
rb 'lines.take_while{|l|l!="quit"}.puts'
Play rock, paper, scissors:
rb 'doing{["rock", "paper", "scissors"].sample}.take(2).puts'