2014-03-01   task   bash   mac 

「このプロジェクトはこのディレクトリで作業する」を指定するコマンド

前提

問題

解法

詳細

here

#!/usr/bin/env ruby

ALIAS_FILE = '$HOME/.here'

if ARGV.length != 1
  puts "Usage: here project-code"
  puts "Example: here math"
  puts
  puts "pwd is clipped."
  system("pwd | pbcopy")
  abort
end

PROJECT_CODE = ARGV[0]
CMDLINE = "alias #{PROJECT_CODE}='pushd #{Dir.pwd}'"
# CMDLINE = "alias #{PROJECT_CODE}='pushd #{Dir.pwd}; show_todo'"
File::open(ALIAS_FILE, "a+") do |f|
  f.puts(CMDLINE)
end

puts "#{ALIAS_FILE} is updated.\n#{CMDLINE}"
system("echo source ~/.here | pbcopy")
puts "Execute Command+V on the command line to execute \"source ~/.here\""
 2014-03-01   task   bash   mac