From d088f7a282c9252d2a54c3f15f6c02d24f0070b8 Mon Sep 17 00:00:00 2001 From: Aleksei Kaminin Date: Sat, 17 Dec 2011 20:51:35 +0400 Subject: [PATCH] Loading user commands --- README | 3 +++ cards | 3 +++ cards_helper.rb | 7 +++++++ commands.rb | 8 -------- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README b/README index fdc08c2..fb632cc 100644 --- a/README +++ b/README @@ -56,3 +56,6 @@ default_dir: ~/gtd/unsorted Команды описываются в файле commands.rb Кнопки описываются в rc.yaml + +------------------------------------ +Свои команды можно записывать в файл ~/.bu_commands.rb diff --git a/cards b/cards index e049d2b..16de73c 100755 --- a/cards +++ b/cards @@ -33,6 +33,9 @@ require "lib/bind.rb" require "commands.rb" +user_commands_file = File.expand_path "~/.bu_commands.rb" +require user_commands_file if File.exist? user_commands_file + require "rubygems" require "backports" require "natural_sort_kernel" diff --git a/cards_helper.rb b/cards_helper.rb index 1eb6346..bca4d75 100644 --- a/cards_helper.rb +++ b/cards_helper.rb @@ -142,3 +142,10 @@ def goto_file_mode file default_file_action file do_what_i_say_in_file file end + +def goto_dir_mode dir + clear + show_current_dir_line dir + default_dir_action dir + do_what_i_say_in_dir dir +end diff --git a/commands.rb b/commands.rb index fe3bb8f..52d5f69 100644 --- a/commands.rb +++ b/commands.rb @@ -1,11 +1,3 @@ - -dir_cmd :goto_dir_mode do |dir| - clear - show_current_dir_line dir - default_dir_action dir - do_what_i_say_in_dir dir -end - dir_cmd :go_upper_dir do |dir| goto_dir_mode ex_pth(fjoin(dir, '..')) end