Skip to content

Commit

Permalink
Fixed home dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Bubujka committed Jul 20, 2014
1 parent e340529 commit 32f9054
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
22 changes: 9 additions & 13 deletions cards
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ require "yaml"
require "optparse"

require "stringio"
require "fileutils"
require "rubygems"
require "backports"
require "colored"
require "ya2yaml"
require "natural_sort_kernel"

require "highline/system_extensions"


require "./lib/hash.rb"
Expand All @@ -12,7 +20,6 @@ require "./class.rb"
require "./cards_helper.rb"
require "./dir_mode.rb"
require "./file_mode.rb"
require "fileutils"
require "./lib/def.rb"
require "./lib/bind.rb"
require "./lib/flash.rb"
Expand All @@ -23,13 +30,6 @@ 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

require "rubygems"
require "backports"
require "colored"
require "ya2yaml"
require "natural_sort_kernel"

require "highline/system_extensions"
include HighLine::SystemExtensions

$options = {:config => "~/.cardsrc"}
Expand All @@ -51,11 +51,7 @@ end.parse!


def home_dir
if have_args?
ARGV[0].ex
else
rc("default_dir").ex
end
ARGV[0].ex
end

def main
Expand Down
3 changes: 0 additions & 3 deletions cards_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,6 @@ def title wtf
# todo
end

def default_dir
rc "default_dir"
end
$watched = {}
def random_file_in dir
$watched[dir] = [] unless $watched[dir]
Expand Down
7 changes: 4 additions & 3 deletions class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ def content= what

def strip_home
t = self.dup
return "" if t == home_dir
t[home_dir() + '/'] = ""
t
if t == home_dir
return ""
end
t.sub(home_dir() + '/', '')
end

def ex
Expand Down
4 changes: 2 additions & 2 deletions commands/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
end

global_cmd :goto_random_in_default_dir do |pth, mode|
random_files = `find #{default_dir}/* -type f | sort -R`.split "\n"
random_files = `find #{home_dir}/* -type f | sort -R`.split "\n"
goto_file_mode random_files.first
end

global_cmd :go_home do |pth, mode|
goto_dir_mode rc("default_dir").ex
goto_dir_mode home_dir
end

global_cmd :show_help do |pth, mode|
Expand Down

0 comments on commit 32f9054

Please sign in to comment.