Skip to content

Commit

Permalink
Splited file with commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Bubujka committed Dec 27, 2011
1 parent a267d57 commit b64ae1b
Show file tree
Hide file tree
Showing 5 changed files with 259 additions and 258 deletions.
2 changes: 1 addition & 1 deletion cards
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require "fileutils.rb"
require "lib/def.rb"
require "lib/bind.rb"

require "commands.rb"
Dir.glob(File.dirname(__FILE__) + '/commands/*', &method(:require))

user_commands_file = File.expand_path "~/.bu_commands.rb"
require user_commands_file if File.exist? user_commands_file
Expand Down
257 changes: 0 additions & 257 deletions commands.rb

This file was deleted.

82 changes: 82 additions & 0 deletions commands/dir.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
dir_cmd :git_add_clear_and_autocommit do |dir|
clear
puts system("cd #{dir}; git add .; /home/waserd/.db/bin/stable/git-clear; /home/waserd/.db/bin/git-autocommit; git push")
char_gets
end

dir_cmd :goto_prj_file do |dir|
goto_file_mode ex_pth(fjoin(dir, '.prj'))
end

dir_cmd :select_and_goto_dir do |dir|
dirs = dirs_in_pth dir
return if dirs.empty?

clear
num = 0
arr = []

dirs.each_index do |i|
arr.push " #{i+1}: #{dirs[i]}"
end

pp_list arr, "= Select dir in #{dir} ="
t = gets.chomp
return unless t =~ /^[0-9]+$/
num = t.to_i - 1
goto_dir_mode fjoin(dir, dirs[num])
end

dir_cmd :select_and_goto_file do |dir|
files = files_in_pth(dir)
return if files.empty?
clear
num = 0
pp_list files.each_index.map{|i| " #{i+1}: #{files[i]}"}, "= Select file in #{dir} ="
t = gets.chomp
return unless t =~ /^[0-9]+$/
num = t.to_i - 1
goto_file_mode fjoin(dir, files[num])
end

dir_cmd :create_dir_with_user_name do |dir|
clear
print "Enter dir name: "
name = gets.chomp
FileUtils::mkdir(dir = fjoin(dir, name))
goto_dir_mode dir
end


dir_cmd :edit_new_file_with_next_name do |dir|
next_num = find_next_num_in_dir dir
pth = fjoin(dir, next_num.to_s)
FileUtils::touch(pth)
system "#{editor} #{pth}"
goto_file_mode pth
end

dir_cmd :edit_new_file_with_user_name do |dir|
clear
print "Enter file name: "
name = gets.chomp
pth = fjoin(dir, name)
FileUtils::touch(pth)
system "#{editor} #{pth}"
goto_file_mode pth
end

doc "Перейти на каталог выше"
dir_cmd :go_upper_dir do |dir|
goto_dir_mode ex_pth(fjoin(dir, '..'))
end

doc "Перейти к случайному файлу в текущем каталоге"
dir_cmd :rnd_file_in_dir do |dir|
if !files_in_pth(dir).empty?
goto_file_mode random_file_in(dir)
else
goto_dir_mode dir
end
end

Loading

0 comments on commit b64ae1b

Please sign in to comment.