Created
October 20, 2009 00:19
-
-
Save BanzaiMan/213868 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Termtter::Client | |
| config.plugins.edit_plugin.set_default(:local_dir, File.join(config.system.conf_dir, 'plugins')) | |
| config.plugins.edit_plugin.set_default(:editor, ENV["EDITOR"] || ENV["VISUAL"] || '') | |
| if config.plugins.edit_plugin.editor.empty? | |
| warn "Unable to determine appropriate editor command" | |
| return | |
| end | |
| register_command( | |
| :name => :edit_plugin, | |
| :aliases => [:ep], | |
| :help => ["edit_plugin", "opens editor to edit the specified local plugin"], | |
| :completion_proc => lambda {|cmd, arg| | |
| Dir.entries(config.plugins.edit_plugin.local_dir).select{ |f| f =~ /^[^\.]\S*\.rb$/}.map{|f| "#{cmd} #{f}"} | |
| }, | |
| :exec => lambda { |plugin| | |
| raise ArgumentError, "plugin name not specified" if plugin.empty? | |
| plugin += ".rb" unless plugin =~ /\.rb$/ | |
| begin | |
| cmd = [ | |
| "exec", | |
| config.plugins.edit_plugin.editor, | |
| File.join(config.plugins.edit_plugin.local_dir,plugin) | |
| ] | |
| call_commands(cmd.join(" ")) | |
| rescue Exception => e | |
| handle_error(e) | |
| end | |
| } | |
| ) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment