From 82308f926cb9ce30d958fe04878004fdd6d47849 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 8 Jul 2010 13:22:28 -0400 Subject: Initial commit --- Makefile | 12 ++++++++ bin/build | 28 ++++++++++++++++++ bin/git-un-diff-whitespace | 72 ++++++++++++++++++++++++++++++++++++++++++++++ bin/inroot | 10 +++++++ bin/inroot-build | 5 ++++ bin/inroot~ | 9 ++++++ dotfiles/bashrc | 28 ++++++++++++++++++ dotfiles/emacs | 43 +++++++++++++++++++++++++++ 8 files changed, 207 insertions(+) create mode 100644 Makefile create mode 100755 bin/build create mode 100755 bin/git-un-diff-whitespace create mode 100755 bin/inroot create mode 100755 bin/inroot-build create mode 100755 bin/inroot~ create mode 100644 dotfiles/bashrc create mode 100644 dotfiles/emacs diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..40f734d --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +all: + +install: + mkdir -p $HOME/bin 2>/dev/null + for f in bin/*; do \ + bn=$(basename $f); \ + ln -sf $(pwd)/bin/$f ~/bin \ + done + for f in dotfiles/*; do \ + bn=$(basename $f); \ + ln -s $(pwd)/dotfiles/$f ~/.bn \ + done diff --git a/bin/build b/bin/build new file mode 100755 index 0000000..b33955d --- /dev/null +++ b/bin/build @@ -0,0 +1,28 @@ +#!/bin/bash +set -e +set -x +root=$INROOT_DIR +if test -z "$root"; then + echo "INROOT_DIR not set; run under inroot" + exit 1 +fi +shift || true +if ! test -x configure; then + if test -d /lib64; then + libdir=$root/lib64 + else + libdir=$root/lib + fi + configargs="--prefix=$root --libdir=$libdir $@" + if test -f autogen.sh; then + inroot $root ./autogen.sh $configargs + else + autoreconf -f -i + inroot $root configure $configargs + fi +fi +if ! test -f Makefile; then + inroot $root configure $configargs +fi +nproc=$(($(grep -c ^processor /proc/cpuinfo) * 2)) +make -j $nproc $MAKEARGS diff --git a/bin/git-un-diff-whitespace b/bin/git-un-diff-whitespace new file mode 100755 index 0000000..0431c80 --- /dev/null +++ b/bin/git-un-diff-whitespace @@ -0,0 +1,72 @@ +#!/usr/bin/python + +import os,sys,re,subprocess + +hunk_re = re.compile(r'^@@ -\d+,\d+ \+(\d+),(\d+) @@') +ws_re = re.compile(r'^(.*?)[ \t]+$') +file_re = re.compile(r'^\+\+\+ b/(.+)') + +def strip_whitespace_regions(filename, hunks): + if len(hunks) == 0: + return + filename_t = filename + '.tmp' + tmpf = open(filename_t, 'w') + f = open(filename) + i = 0 + hunk = hunks[0] + for line in f: + if (hunk is None) or (i < hunk[0]): + tmpf.write(line) + elif i < (hunk[0] + hunk[1]): + nline = ws_re.sub(r'\1', line) + tmpf.write(nline) + else: + hunks = hunks[1:] + if len(hunks) == 0: + hunk = None + else: + hunk = hunks[0] + tmpf.write(line) + i = i+1 + tmpf.close() + f.close() + os.rename(filename_t, filename) + print "wrote " + filename + +def main(): + toplevel = subprocess.Popen(['git', 'rev-parse', '--show-toplevel'], stdout=subprocess.PIPE).communicate()[0] + os.chdir(toplevel[:-1]) + diff = subprocess.Popen(['git', 'diff'], stdout=subprocess.PIPE).communicate()[0] + if diff != '': + print "You have unstaged changes; Commit them or 'git stash'" + sys.exit(1) + commit_proc = subprocess.Popen(['git', 'show', '-p', 'HEAD'], stdout=subprocess.PIPE, + stderr=sys.stderr) + diff_lines = commit_proc.stdout.readlines() + commit_proc.wait() + subprocess.check_call(['git', 'reset', 'HEAD^'], stdout=sys.stdout, stderr=sys.stderr) + curfile = None + hunks = [] + files = [] + for line in diff_lines: + if curfile is not None: + match = hunk_re.match(line) + if match: + hunks.append((int(match.group(1)),int(match.group(2)))) + continue + match = file_re.match(line) + if match: + filename = match.group(1) + strip_whitespace_regions(curfile, hunks) + curfile = filename + files.append(filename) + hunks = [] + if curfile: + strip_whitespace_regions(curfile, hunks) + add_args = ['git', 'add'] + add_args.extend(files) + subprocess.check_call(add_args, stdout=sys.stdout, stderr=sys.stderr) + subprocess.check_call(['git', 'commit', '-c', 'ORIG_HEAD'], stdout=sys.stdout, stderr=sys.stderr) + +if __name__ == '__main__': + main() diff --git a/bin/inroot b/bin/inroot new file mode 100755 index 0000000..ca03656 --- /dev/null +++ b/bin/inroot @@ -0,0 +1,10 @@ +#!/bin/sh +set -e +root=$1 +shift +if test -d /lib64; then + libext=64 +else + libext= +fi +exec env INROOT_DIR=${root} XDG_DATA_DIRS=${root}/share LD_LIBRARY_PATH=${root}/lib${libext} PATH=${root}/bin:${PATH} PKG_CONFIG_PATH=${root}/lib${libext}/pkgconfig PYTHONPATH=${root}/lib${libext}/python2.5/site-packages "$@" diff --git a/bin/inroot-build b/bin/inroot-build new file mode 100755 index 0000000..afd4052 --- /dev/null +++ b/bin/inroot-build @@ -0,0 +1,5 @@ +#!/bin/bash +set -e +root=$1 +shift +exec inroot $root build "$@" diff --git a/bin/inroot~ b/bin/inroot~ new file mode 100755 index 0000000..3903ad7 --- /dev/null +++ b/bin/inroot~ @@ -0,0 +1,9 @@ +#!/bin/sh +root=$1 +shift +if test -d /lib64; then + libext=64 +else + libext= +fi +exec env INROOT_DIR=${root} XDG_DATA_DIRS=${root}/share LD_LIBRARY_PATH=${root}/lib${libext} PATH=${root}/bin:${PATH} PKG_CONFIG_PATH=${root}/lib${libext}/pkgconfig PYTHONPATH=${root}/lib${libext}/python2.5/site-packages "$@" diff --git a/dotfiles/bashrc b/dotfiles/bashrc new file mode 100644 index 0000000..7abf9bd --- /dev/null +++ b/dotfiles/bashrc @@ -0,0 +1,28 @@ +# .bashrc + +# Source global definitions +if [ -f /etc/bashrc ]; then + . /etc/bashrc +fi + +# User specific aliases and functions + +if [ -f /etc/bash_completion ]; then + . /etc/bash_completion +fi + +shopt -s histappend + +EDITOR="emacsclient" +export EDITOR + +_format_inroot_dir () +{ + if test -n "$INROOT_DIR"; then + echo " [root=$INROOT_DIR]" + fi +} + +PS1='\W$(_format_inroot_dir)$(__git_ps1 " [git %s]") \$ ' +export PS1 + diff --git a/dotfiles/emacs b/dotfiles/emacs new file mode 100644 index 0000000..9c225a5 --- /dev/null +++ b/dotfiles/emacs @@ -0,0 +1,43 @@ +;;; Minimal Unbreak Emacs +; Waste of display space if you can't click on it +(menu-bar-mode nil) +; This is off for efficiency reasons I guess. But really +; Emacs should have some heuristics for it instead of being +; dumb by default. +(column-number-mode t) +; Really. +(iswitchb-mode t) +; Assuming you didn't use Emacs from before when the concept of +; selecting a single region of text interactively was not supported. +(transient-mark-mode t) +; This one is actually fixed in Emacs 22; http://www.emacswiki.org/cgi-bin/wiki/CopyAndPaste +(setq x-select-enable-clipboard t) +; The default for "uniquifying" buffer names sucks +(require 'uniquify) +(setq uniquify-buffer-name-style 'post-forward-angle-brackets) +; Slightly more debatable +(global-set-key (kbd "C-x C-b") 'ibuffer) +(set-scroll-bar-mode 'right) +; Custom keybindings +(global-set-key (kbd "C-c i") 'imenu) +;;; End Minimal Unbreak Emacs + +(global-set-key (kbd "C-z") 'undo) +(tool-bar-mode nil) +(server-start) +(setq viper-mode t) +(require 'viper) + +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(safe-local-variable-values (quote ((js2-basic-offset . 4))))) +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + ) +(put 'narrow-to-region 'disabled nil) -- cgit