Skip to content

Instantly share code, notes, and snippets.

@chsh
Last active October 8, 2017 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chsh/3c59ef2f236c82e45ecf0b7c51dcea09 to your computer and use it in GitHub Desktop.
Save chsh/3c59ef2f236c82e45ecf0b7c51dcea09 to your computer and use it in GitHub Desktop.
irbでソースコードフォルダ毎に履歴を分けて保存する ref: http://qiita.com/chshii/items/ba10dcc8dcc24b315d16
require 'irb/ext/save-history'
IRB.conf[:SAVE_HISTORY] = 80000 # このあたりはお好みで。
require 'digest/md5'
require 'fileutils'
history_base = File.join(ENV['HOME'], '.irb', 'histories')
FileUtils.mkdir_p history_base unless Dir.exist? history_base
pwd_hash = Digest::MD5.hexdigest(`pwd`.chomp)
IRB.conf[:HISTORY_FILE] = File.join(history_base, pwd_hash)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment