以åããï¼Gitã®ãªãã¸ããªã®ç¶æ
ãªã©ãzshã®ããã³ããã«è¡¨ç¤ºãã¦ããã®ã ãã©ï¼precmdã®ããã¯ã§git logã¨ãgit statusãä½åº¦ãå¼ã°ãã¦ãã¦ï¼å¤§å¤é
ãã£ãï¼
ããã³ãããåºãã¾ã§ä½ãæä½ã§ããªãã¦ï¼å°ã£ã¦ããã®ã§ï¼dRubyã§ï¼éåæã«ãªãã¸ããªã®ç¶æ
ã調ã¹ã¦ï¼Growlã§éç¥ããããã«ããï¼
ä½ãã³ãã³ããå®è¡ãããã³ã«ï¼ãªãã¸ããªã®æ
å ±ãGrowlã§åºã¦ããã®ã§ï¼å¸¸ã«ï¼èªåãä½ããã¦ããã®ãæ°ã«ãããã¨ãã§ããï¼
ãããäºãã©ããã§èµ·åãã¦ããã¦ï¼
#! /opt/local/bin/ruby require 'rubygems' require 'drb/drb' require 'git' require 'g' class Service def git_status(path) Thread.new { path = File.expand_path path git = Git.open(path) rescue return g git.current_branch changed = git.status.changed.length g "#{changed} changes" if changed > 0 local = git.log(1).between('origin', 'HEAD').count g "#{local} local commits" if local > 0 } end end uri = ARGV.shift || 'druby://localhost:12345' DRb.start_service(uri, Service.new) puts DRb.uri sleep
ãã®ã¹ã¯ãªãããï¼ãã¹ã®éã£ãã¨ããã«ç½®ãã¦ï¼
#! /opt/local/bin/ruby require 'rubygems' require 'drb/drb' there = DRbObject.new_with_uri('druby://localhost:12345') there.git_status(Dir.pwd)
.zshrcã§ï¼precmdã®ããã¯ã§å®è¡ããããã«ããï¼
precmd () { git_status }
GitHubã«ç½®ããï¼
http://gist.github.com/310741
ä½æé度ãä¸ãã£ãã®ã§ï¼Gitã«éããï¼éãå¦çãprecmdã§ããããã¨ãã¯ï¼dRubyã«å¦çãããã¨ããæãã«ãªãããï¼
追è¨
ã©ããåããããããæ°ãããï¼branchããã£ã¨masterã«ãªã£ã¦ãï¼
追è¨2
ç´ããï¼
git.branch
ããã¨ï¼ä»ãã§ãã¯ã¢ã¦ãããã¦ããã©ã³ããããããã¨æã£ã¦ãããï¼ããã§ã¯ãªãã¦ï¼ãã®ã¡ã½ããã¯ï¼
git.branch("piyo")
ã¨ããã¦ï¼æå®ããååã®ãã©ã³ããåå¾ããã¡ã½ããã ã£ãï¼ååãçç¥ããã¨masterã«ãªãï¼
ç¾å¨ãã§ãã¯ã¢ã¦ããã¦ãããã©ã³ããåå¾ããã«ã¯ï¼
git.current_branch
ããï¼ããããã¨ï¼ç¾å¨ãã§ãã¯ã¢ã¦ããã¦ãã(ãã©ã³ãã®ãªãã¸ã§ã¯ãã§ã¯ãªãã¦ï¼)ãã©ã³ãã®ååãåå¾ã§ããï¼æ³åã絶ããæãã ãã©ï¼ããããä»æ§ã ã£ãï¼