lib/aka/config.rb in aka2-0.1.10.pre vs lib/aka/config.rb in aka2-0.1.10

- old
+ new

@@ -1,7 +1,8 @@ -module Aka +require_relative './dependencies.rb' +module Aka def self.setup_aka userBash = [] # 1. check for each type of file without setting anything. if File.exist?("#{ZSHRC_PATH}") #if zshrc exist userBash.push(".zshrc") @@ -23,15 +24,16 @@ set_to_dotfile(userBash.first) elsif userBash.count > 1 #4 if the number of types is more than 1, proceed to ask which one does the users want to uses. userBash.each_with_index do |choice,i| - puts "#{i+1}. Setup in #{Dir.home}/#{choice}" + puts "#{i+1}. Setup at #{Dir.home}/#{choice}" end - choice = ask "Please choose which location you wish to setup? (Choose a number and enter)\n" - #5 once you receive input, then you set it according to input + puts ("Where do you wish to setup aka? (Pick a number and enter)\n") + choice = STDIN.gets.chomp + case choice when "1" set_to_dotfile(userBash[0]) if userBash[0] when "2" if userBash[1] then set_to_dotfile(userBash[1]) else abort "No file choosen" end @@ -69,30 +71,32 @@ setPROFILE end end def self.setup_autosource - if File.exist?("#{CONFIG_PATH}") - out_file = File.new("#{CONFIG_PATH}/autosource", "w") + if File.exist?("#{AKA_PATH}") + FileUtils.touch("#{AKA_PATH}/autosource") + out_file = File.new("#{AKA_PATH}/autosource", "w") out_file.puts("export HISTSIZE=10000") out_file.puts("sigusr2() { unalias $1;}") out_file.puts("sigusr1() { source #{readYML("#{CONFIG_PATH}")["dotfile"]}; history -a; echo 'reloaded dot file'; }") out_file.puts("trap sigusr1 SIGUSR1") out_file.puts("trap 'sigusr2 $(cat ~/sigusr1-args)' SIGUSR2") out_file.close - autosource = "\nsource \"#{CONFIG_PATH}/autosource\"" + autosource = "\nsource \"#{AKA_PATH}/autosource\"" append(autosource, readYML("#{CONFIG_PATH}")['profile']) puts "Done. Please restart this shell.".red else puts "Directory #{CONFIG_PATH} doesn't exist" end end def self.setup_config if File.exist?("#{CONFIG_PATH}") puts "Directory #{CONFIG_PATH} exist" else - FileUtils::mkdir_p("#{CONFIG_PATH}") + FileUtils.mkdir_p("#{AKA_PATH}") + FileUtils.touch("#{CONFIG_PATH}") out_file = File.new("#{CONFIG_PATH}", "w") out_file.puts("---") out_file.puts("dotfile: \"/home/user/.bashrc\"") out_file.puts("history: \"/home/user/.bash_history\"") out_file.puts("home: \"/home/user/.aka\"") @@ -158,9 +162,9 @@ setPath("/etc/profile","profile") setPath("#{AKA_PATH}","home") end def self.isOhMyZsh - readYML("#{CONFIG_PATH}")["dotfile"] == "#{ZSHRC_PATH}" ? TRUE : FALSE + readYML("#{CONFIG_PATH}")["dotfile"] == "#{ZSHRC_PATH}" ? true : false end end