レポジトリの状態をscreenのステータスラインに表示する
30分プログラム、その556。レポジトリの状態をscreenのステータスラインに表示する。
ボクは自分の書いた文章やら設定ファイルやらを~/cにつっこんで、gitで管理してる。青木さんのオレポータビリティをマネしてるんだけど。
でも、このレポジトリのコミットをしょっちゅう忘れる。すると、コンフリクトが発生して、とても悲しいことになる。
というわけで、screenのステータスラインにgitレポジトリの状態を表示するようにした。
使い方
backtick 0 0 60 ${HOME}/c/commands/git-notify.scm hardstatus alwayslastline "[%02c](%0`) %-w%{=b bw}%n %t%{-}%+w"
ソースコード
#! /opt/local/bin/gosh ;; -*- mode:scheme; coding:utf-8 -*- ;; ;; git-notify.scm - ;; ;; Copyright(C) 2009 by mzp ;; Author: MIZUNO Hiroki / mzpppp at gmail dot com ;; http://howdyworld.org ;; ;; Timestamp: 2009/03/30 09:56:13 ;; ;; This program is free software; you can redistribute it and/or ;; modify it under MIT Lincence. ;; (define (system str) (= (sys-system str) 0)) (define update? (system "cd ~/c && git status | grep \"Changed but not updated\" > /dev/null")) (define commit? (system "cd ~/c && git status | grep \"Changes to be committed\" > /dev/null")) (define untracked? (system "cd ~/c && git status | grep \"Untracked files\" > /dev/null")) (print (string-append (if update? "U" "") (if commit? "M" "") (if untracked? "?" "")))