#!/usr/bin/env ruby # [Gedit Tool] # Comment=Run the current file # Input=nothing # Name=Run File (Ruby) # Shortcut=F5 # Applicability=all current_file = ENV['GEDIT_CURRENT_DOCUMENT_PATH'] if not current_file puts "The current file cannot be runned." elsif current_file =~ /\.(php|py|rb|html|htm|xml)$/i commands = { 'php' => "php -f #{current_file}", 'rb' => "ruby #{current_file}", 'py' => "python #{current_file}", 'browser' => "firefox -new-tab #{current_file}" } extension = ['html', 'htm', 'xml'].include?($1) ? 'browser' : $1 command = commands[extension] puts "Running command #{command}\n" system(command) end