changeset 129:f18a27a0e8fc

Merge branch.
author Edho Arief <edho@myconan.net>
date Sat, 29 Oct 2011 11:40:35 +0700
parents 0c3b473b9af7 (current diff) 66a1d79c4161 (diff)
children 70928bbbd6cb
files bash hg inputrc tcsh tmux vim zsh
diffstat 32 files changed, 1012 insertions(+), 381 deletions(-) [+]
line wrap: on
line diff
--- a/bash	Sat Oct 29 11:40:03 2011 +0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-#!/usr/bin/env bash
-
-if [ "${ECOS_BASH_LOADED}" != "yes" ]; then
-
-export ECOS_BASH_LOADED="yes"
-
-[ -f "${HOME}/.ecos_bash.before" ] && . "${HOME}/.ecos_bash.before"
-
-_org_path="${PATH}"
-export PATH="${HOME}/.ecos_bin:${HOME}/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
-
-PS1='[\u@\h \W]\$ '
-#PS1='[\[\e[0;33m\]\u\[\e[0m\]@\[\e[0;32m\]\h\[\e[0m\] \[\e[1;34m\]\W\[\e[0m\]]\$ '
-
-shopt -s histappend
-PROMPT_COMMAND='history -a'
-export HISTFILESIZE=10000
-export HISTCONTROL=ignoredups
-
-export PAGER="less -Rins"
-export EDITOR=vi
-export LANG="en_US.UTF-8"
-unset LS_COLORS
-
-alias less="less -Rins"
-#assuming POSIX grep
-alias fgrep="grep -F"
-alias egrep="grep -E"
-alias ls="ls -F"
-alias rm="rm -i"
-alias rd="rdesktop -g 1280x600 -K -a 16 -z -P -r sound:off -r clipboard:CLIPBOARD -5"
-
-_has_rm_I=
-_has_gnu_ls=
-_has_gnu_grep=
-case "$(uname -s)" in
-  Linux)
-    _has_rm_I=y
-    _has_gnu_ls=y
-    _has_gnu_grep=y
-  ;;
-  SunOS)
-    [ -x /usr/gnu/bin/rm ] && _has_rm_I=y
-    [ -x /usr/gnu/bin/ls ] && _has_gnu_ls=y
-    [ -x /usr/gnu/bin/grep ] && _has_gnu_grep=y
-    [ -d /usr/xpg4/bin ] && PATH="/usr/xpg4/bin:${PATH}"
-    [ -d /opt/csw/bin ] && PATH="/opt/csw/bin:${PATH}"
-    [ -d /opt/csw/sbin ] && PATH="/opt/csw/sbin:${PATH}"
-    [ -d /usr/gnu/bin ] && PATH="/usr/gnu/bin:${PATH}"
-    export PATH
-    alias ping="ping -s"
-    alias ping6="ping -A inet6"
-  ;;
-  FreeBSD)
-    _has_rm_I=y
-    export CLICOLOR=
-    export LSCOLORS=ExGxFxdxCxegedabagExEx
-  ;;
-  OpenBSD)
-    if command -v colorls > /dev/null 2>&1; then
-      export CLICOLOR=
-      alias ls='colorls -F'
-    fi
-  ;;
-  CYGWIN*)
-    export PATH="${PATH}:${_org_path}"
-  ;;
-esac
-
-[ "${_has_rm_I}" = y ] && alias rm="rm -I"
-[ "${_has_gnu_ls}" = y ] && alias ls="ls -F --color=auto"
-[ "${_has_gnu_grep}" = y ] && alias grep="grep --color=auto"
-
-unset _has_rm_I
-unset _has_gnu_ls
-unset _has_gnu_grep
-
-
-case "${TERM}" in
-  xterm*|screen*|dtterm)
-    PROMPT_COMMAND='echo -ne "\033]0;${LOGNAME}@${HOSTNAME}: ${PWD}\007"'
-  ;;
-esac
-
-if command -v vim > /dev/null 2>&1; then
-  alias vi=vim
-  export EDITOR=vim
-fi
-[ -f "${HOME}/.ecos_bash.after" ] && . "${HOME}/.ecos_bash.after"
-
-fi
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/256colors2.pl	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+# Author: Todd Larason <jtl@molehill.org>
+# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $
+
+# use the resources for colors 0-15 - usually more-or-less a
+# reproduction of the standard ANSI colors, but possibly more
+# pleasing shades
+
+# colors 16-231 are a 6x6x6 color cube
+for ($red = 0; $red < 6; $red++) {
+    for ($green = 0; $green < 6; $green++) {
+	for ($blue = 0; $blue < 6; $blue++) {
+	    printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\",
+		   16 + ($red * 36) + ($green * 6) + $blue,
+		   ($red ? ($red * 40 + 55) : 0),
+		   ($green ? ($green * 40 + 55) : 0),
+		   ($blue ? ($blue * 40 + 55) : 0));
+	}
+    }
+}
+
+# colors 232-255 are a grayscale ramp, intentionally leaving out
+# black and white
+for ($gray = 0; $gray < 24; $gray++) {
+    $level = ($gray * 10) + 8;
+    printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\",
+	   232 + $gray, $level, $level, $level);
+}
+
+
+# display the colors
+
+# first the system ones:
+print "System colors:\n";
+for ($color = 0; $color < 8; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n";
+for ($color = 8; $color < 16; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n\n";
+
+# now the color cube
+print "Color cube, 6x6x6:\n";
+for ($green = 0; $green < 6; $green++) {
+    for ($red = 0; $red < 6; $red++) {
+	for ($blue = 0; $blue < 6; $blue++) {
+	    $color = 16 + ($red * 36) + ($green * 6) + $blue;
+	    print "\x1b[48;5;${color}m  ";
+	}
+	print "\x1b[0m ";
+    }
+    print "\n";
+}
+
+
+# now the grayscale ramp
+print "Grayscale ramp:\n";
+for ($color = 232; $color < 256; $color++) {
+    print "\x1b[48;5;${color}m  ";
+}
+print "\x1b[0m\n";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/basicopt	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,11 @@
+#!/bin/sh
+get_filename() {
+	printf "%s\n" "$*" | sed -e 's/^\(.*\)\.[^.]*$/\1/'
+}
+get_extension() {
+	if [ -n "$(printf "%s\n" "$*" | sed -e 's/^[^.]*//')" ]; then
+		printf "%s\n" "$*" | sed -e 's/^.*\(\.[^.]*$\)/\1/'
+	else
+		printf "%s\n" ""
+	fi
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/cek.pl	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use String::CRC32;
+use File::Basename;
+
+my @files = @ARGV or print("Usage: ",basename($0)," file1 file2 ... fileN\n") && exit(1);
+my $num_ok=0;
+my $num_err=0;
+my $num_nf=0;
+my $num_na=@files;
+
+foreach(@files) {
+	my $filename = $_;
+	my ($name_crc,$real_crc);
+	unless (-f $filename) {
+		$num_nf++;$num_na--;
+		print(qq(Could not find "$filename", skipping\n));
+		next();
+	}
+	if(/(\[|\()([0-9A-F]{8})(\]|\))/i){
+		$name_crc=uc($2);
+	}
+	open(FILE,"<",$filename);
+	binmode(FILE);
+	$real_crc=sprintf("%08X",crc32(*FILE));
+	close(FILE);
+	if($name_crc) {
+		$num_na--;
+		if($name_crc eq $real_crc) {
+			$num_ok++;
+			print("$filename: OK - $real_crc\n");
+		} else {
+			$num_err++;
+			print("$filename: NOT OK - $real_crc, should be $name_crc\n");
+		}
+	} else {
+		print("$filename: $real_crc\n");
+	}
+}
+
+printf("%s\n","-"x40);
+if($num_ok > 0) { print("Files OK: $num_ok\n"); }
+if($num_err > 0) { print("Files error: $num_err\n"); }
+if($num_nf > 0) { print("Files not found: $num_nf\n"); }
+if($num_na > 0) { print("Files without crc information: $num_na\n"); }
+
+exit(0);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/cek.rb	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+require 'zlib'
+
+block = 1048576
+ARGV.each do |filename|
+	crc = 0
+	file = File.open(filename, 'rb')
+	currentbyte = 0
+	while (line = file.read(block)) do
+		crc = Zlib.crc32(line,crc)
+	end
+	file.close
+	printf("%s %08X\n", filename, crc.to_s)
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/ed2k.py	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+
+import os, sys
+from Crypto.Hash import MD4
+
+def ed2k(filename):
+  block = 9500*1024
+  hash = ""
+  file = open(filename, "rb")
+  fileblock = file.read(block)
+  while fileblock:
+    hash += MD4.new(fileblock).digest()
+    fileblock = file.read(block)
+  file.close()
+  return MD4.new(hash).hexdigest()
+
+if __name__ == "__main__":
+  for file in sys.argv[1:]:
+    print "%s %s" %(ed2k(file), file)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/index	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,176 @@
+#!/bin/sh
+
+#un(POSIX / bourne shell)-ness: "read -r"
+
+WORKDIR="${PWD}"
+TEMPFILE="${WORKDIR}/temp/all"
+RESFILE="${WORKDIR}/list/all"
+ARCDIR="${WORKDIR}/archives"
+FILEDIRS="complete1 complete3 complete4 complete5 incomplete movie"
+#FILEDIRS="complete-all incomplete movie"
+
+Err_Fatal() {
+	echo "Error: $*"
+	exit 1
+}
+
+Progress_Init() {
+	_last="-"
+	printf "${_last}"
+}
+
+Progress_Anim() {
+	case "${_last}" in
+		/) _last="-";;
+		-) _last=\\;;
+		\\) _last=\|;;
+		\|) _last="/";;
+	esac
+	printf "\b${_last}"
+}
+
+Progress_Done() { printf "\bdone\n"; }
+
+Check_Dirs() {
+	[ -w "${WORKDIR}" ] || Err_Fatal "Unable to write ${WORKDIR}"
+	for dir in temp list archives backup; do
+		mkdir -p "${WORKDIR}/${dir}" 2>/dev/null
+		[ -w "${WORKDIR}/${dir}" ] || Err_Fatal "Unable to write ${WORKDIR}/${dir}"
+	done
+}
+
+Finish_Copy() {
+	printf "Copying result files... "
+	rm "${WORKDIR}/list/"*
+	cp "${WORKDIR}/temp/"* "${WORKDIR}/list"
+	mkdir -p "archives/${DATE}" && cp "${WORKDIR}/temp/"* "${WORKDIR}/archives/${DATE}"
+	echo "done"
+}
+
+Generate_File_List() {
+	printf "Generating list of files... "
+	> "${TEMPFILE}-bare"
+	for i in ${FILEDIRS}; do
+		printf "${i}... "
+		dir="/anime/${i}"
+		[ -d "${dir}" ] && find "${dir}/"* -type f >> "${TEMPFILE}-bare"
+	done
+	echo "done"
+	printf "Checking list validity... "
+	[ -n "$(grep -v ^/ "${TEMPFILE}-bare")" ] && Err_Fatal "Newline in filename. Please check ${TEMPFILE}-bare"
+	echo "done"
+
+	printf "Generating list of filenames... "
+	sed -e 's/.*\/\([^/]*\)/\1/' "${TEMPFILE}-bare" > "${TEMPFILE}-basename"
+	echo "done"
+
+	printf "Sorting and finding duplicates... "
+	sort -- "${TEMPFILE}-basename" > "${TEMPFILE}-basename-sorted"
+	mv -- "${TEMPFILE}-basename-sorted" "${TEMPFILE}-basename"
+	sort -u -- "${TEMPFILE}-basename" > "${TEMPFILE}-basename-sortuniq"
+	comm -23 -- "${TEMPFILE}-basename" "${TEMPFILE}-basename-sortuniq" > "${TEMPFILE}-dup-basename"
+	echo "done"
+	if [ "$(wc -l < "${TEMPFILE}-dup-basename")" -gt 0 ]; then 
+		> "${TEMPFILE}-dup-bare"
+		printf "Duplicate files detected. Generating list of duplicates... "
+		Progress_Init
+		while read -r dup; do
+			fgrep "${dup}" "${TEMPFILE}-bare" >> "${TEMPFILE}-dup-bare"
+			Progress_Anim
+		done < "${TEMPFILE}-dup-basename"
+		Progress_Done
+		Err_Fatal "Duplicated files detected. Please resolve this before continuing.
+       Check ${TEMPFILE}-dup-basename for list of duplicates"
+	else
+		rm "${TEMPFILE}-dup-basename" "${TEMPFILE}-basename-sortuniq"
+	fi
+	#yay finished
+}
+
+Generate_New_List() {
+	printf "Generating list of new files... "
+	Progress_Init
+	> "${TEMPFILE}-newbase"
+	sort "${RESFILE}-basename" > "${TEMPFILE}-res-basename"
+	mv "${TEMPFILE}-res-basename" "${RESFILE}-basename"
+	comm -13 "${RESFILE}-basename" "${TEMPFILE}-basename" > "${TEMPFILE}-newbase"
+	Progress_Anim
+	> "${TEMPFILE}-new"
+	while read -r added; do
+		fgrep "${added}" "${TEMPFILE}-bare" >> "${TEMPFILE}-new"
+		Progress_Anim
+	done < "${TEMPFILE}-newbase"
+	rm "${TEMPFILE}-newbase"
+	Progress_Done
+}
+
+Init_Check() {
+	cp "${TEMPFILE}-bare" "${TEMPFILE}-new"
+}
+
+Run_ed2k() {
+	#[ "$(echo $(wc -l < "${TEMPFILE}-new"))" -eq 0 ] && Err_Fatal "Not an error. Just lazy to create new handler. (Nothing new)"
+	printf "Generating ed2k links...0"
+	> "${TEMPFILE}-ed2k-newlist"
+	num=0
+	while read -r file; do
+		ed2k -l "${file}" >> "${TEMPFILE}-ed2k-newlist"
+		num=$((num+1))
+		if [ "$((num%10))" -eq 0 ]; then
+			printf "${num}"
+		else
+			printf "."
+		fi
+	done < "${TEMPFILE}-new"
+	echo " done"
+}
+
+Generate_Removed() {
+	printf "Generating list of removed files... "
+	Progress_Init
+	cp "${TEMPFILE}-ed2k-newlist" "${ARCDIR}/ed2k-newlist.${DATE}"
+	cat "${RESFILE}-ed2k-newlist" >> "${TEMPFILE}-ed2k-newlist"
+	sort -u "${TEMPFILE}-ed2k-newlist" > "${TEMPFILE}-ed2k-newlist-temp"
+	mv "${TEMPFILE}-ed2k-newlist-temp" "${TEMPFILE}-ed2k-newlist"
+	Progress_Anim
+	comm -13 "${TEMPFILE}-basename" "${RESFILE}-basename" | sort > "${TEMPFILE}-removed"
+	Progress_Anim
+	if [ "$(echo $(wc -l < "${TEMPFILE}-removed"))" -gt 0 ]; then
+		> "${TEMPFILE}-ed2k-newlisttemp"
+		while read -r deleted; do
+			fgrep "${deleted}" "${TEMPFILE}-ed2k-newlist" >> "${TEMPFILE}-ed2k-removed"
+			Progress_Anim
+			fgrep -v "${deleted}" "${TEMPFILE}-ed2k-newlist" > "${TEMPFILE}-ed2k-newlisttemp"
+			mv "${TEMPFILE}-ed2k-newlisttemp" "${TEMPFILE}-ed2k-newlist"
+			Progress_Anim
+		done < "${TEMPFILE}-removed"
+		cp "${TEMPFILE}-ed2k-removed" "${ARCDIR}/ed2k-removed.${DATE}"
+		#sed -e 's/ed2k:\/\/|file|\(.*\)|[^|]*|[^|]*|$/\1/' "${TEMPFILE}-ed2k-removed" > "${TEMPFILE}-base-removed"
+		Progress_Anim
+		while read -r deleted; do
+			fgrep "${deleted}" "${RESFILE}-bare" >> "${TEMPFILE}-bare-removed"
+			Progress_Anim
+		done < "${TEMPFILE}-removed"
+		cp "${TEMPFILE}-bare-removed" "${ARCDIR}/bare-removed.${DATE}"
+	fi
+	Progress_Done
+}
+
+INIT=
+UPDATE=
+DATE=$(date -u "+%Y%m%d-%H.%M")
+case "$1" in
+	init) INIT=1;;
+	update|up) UPDATE=1;;
+	*) Err_Fatal "You fail.";;
+esac
+Check_Dirs 
+[ -n "${UPDATE}" ] && cd "${WORKDIR}" && tar zcf "${WORKDIR}/backup/${DATE}.tar.gz" "temp" "list" "archives"
+[ -n "${UPDATE}" ] && rm "${WORKDIR}/temp/"* 2>/dev/null
+Generate_File_List
+[ -n "${INIT}" ] && Init_Check
+[ -n "${UPDATE}" ] && Generate_New_List
+Run_ed2k 
+[ -n "${UPDATE}" ] && Generate_Removed
+Finish_Copy
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/index2	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# Index version 2! Much better than first one. Hopefully.
+
+# Execute safely.
+safe_path()
+{
+	__start=$(printf "%s" | cut -c 1)
+	__path=
+	case "${__start}" in
+		.|/) __path="$*";;
+		*) __path="./$*";;
+	esac
+	printf "%s" "${__path}"
+}
+
+get_basename() { basename "$(safe_path "$*")"; }
+get_basename_pipe() { sed -e 's#.*/\([/]*\)$#\1#'; }
+
+filename_hash()
+{
+	printf "%s" "$(get_basename "$*")" 
+}
+generate_table_of_files()
+{
+	filetable_generator "$@"
+}
+filetable_generator()
+{
+	# Uses perl for speed.
+	perl -e 'use File::Find;
+use Digest::SHA1 qw(sha1_hex);
+use_warnings;
+use_strict;
+sub printer { printf("%s\n", sha1_hex($_)) if(-e && -f && !-l); } 
+find(\&printer, @ARGV);' "$@"
+}
+_srcdir=.
+generate_table_of_files "$@"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/moeauto	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+if [ "$#" -lt 1 ]; then
+	cat <<EOF
+Usage: $(basename -- "$0")
+EOF
+	exit 1
+fi
+
+if [ ! -r "$*" ] || [ -d "$*" ]; then
+	cat <<EOF
+File "$*" can't be read!
+EOF
+	exit 1
+fi
+
+SERVER=
+while read LINE; do
+	if [ -n "$(printf "%s" "${LINE}" | grep "^SERVER=")" ]; then
+		SERVER=$(printf "%s" "${LINE}" | sed -e 's/SERVER=//')
+	else
+		[ -n "${SERVER}" ] && [ ! -z "$(printf "%s" "${LINE}" | grep -v "^$")" ] && moefetch fetch -s "${SERVER}" ${LINE}
+	fi
+done < "$*"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/moeauto-genlink	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+if [ "$#" -lt 1 ]; then
+	cat <<EOF
+Usage: $(basename -- "$0")
+EOF
+	exit 1
+fi
+
+if [ ! -r "$*" ] || [ -d "$*" ]; then
+	cat <<EOF
+File "$*" can't be read!
+EOF
+	exit 1
+fi
+
+SERVER=
+while read LINE; do
+	if [ -n "$(printf "%s" "${LINE}" | grep "^SERVER=")" ]; then
+		SERVER=$(printf "%s" "${LINE}" | sed -e 's/SERVER=//')
+	else
+		[ -n "${SERVER}" ] && [ ! -z "$(printf "%s" "${LINE}" | grep -v "^$")" ] && moefetch check -s "${SERVER}" ${LINE}
+	fi
+done < "$*"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/moedump	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+safe_mv() { mv -- "$@"; }
+safe_ln() { ln -s -- "$1" "$2"; }
+safe_basename() { basename -- "$1"; }
+get_md5() { ${MD5} -- "$1" | cut -d' ' -f1; }
+get_filename() { safe_basename "${1%.*}"; }
+
+eod() { "$@" || errx "$@"; }
+errx() { echo "Error executing: $@"; exit 1; }
+MD5="md5sum"
+[ "$(safe_basename "${PWD}")" = ".all" ] || { echo "Wrong working directory. This script must be run in .all directory. Aborting."; exit 1; }
+
+[ -d "../.trash" ] || eod mkdir ../.trash
+
+echo "Total files: $(find ../* -type f | wc -l) files."
+
+num=0
+for i in ../*/*
+do
+	if [ -h "$i" ]
+	then
+		[ -f "$i" ] || { eod safe_mv "$i" "../.trash" && echo "Broken file: $(safe_basename "$i"). Moved to trash."; }
+	else
+		if [ "$(get_md5 "$i")" = "$(get_filename "$i")" ]
+		then
+			eod safe_mv "$i" . 
+			eod safe_ln "../.all/$(safe_basename "$i")" "$i" 
+		else 
+			eod safe_mv "$i" "../.trash" && echo "Broken file: $(get_filename "$i"). Moved to .trash."
+		fi
+		printf "%s" "."
+		num=$((num+1))
+		[ "$((num%100))" -eq 0 ] && printf "${num}"
+	fi
+done
+
+echo "done"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/old-cek	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,49 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use String::CRC32;
+use File::Basename;
+
+unless($#ARGV+1>0) {
+	print("Usage: ", basename($0), " file1 ... fileN\n");
+	exit(1);
+}
+
+my @files = @ARGV;
+#or print("Usage: ", basename($0), " file1 ... fileN\n") && exit(1);
+    # print usage message if called without arguments
+
+foreach (@files) {
+	my $filename = $_;
+	my ($input, $name_checksum, $real_checksum, $checksum);
+	unless((-r $filename) && (-f $filename)) {
+		print(qq("$filename" is not a file or unreadable, skipping\n));
+		next();
+	}
+	#print(qq(Could not find file "$filename", skipping\n)) and next() unless -r $filename;
+	#print(qq("$filename" is not a file, skipping\n)) and next() unless -f $filename;
+
+	open(FILE,$filename);
+	$real_checksum = sprintf("%08X",crc32(*FILE));
+	close(FILE);
+
+	if ( /(\[|\()([0-9A-F]{8})(\]|\))/i ) { # does it have a checksum?
+		$name_checksum = $2;
+		if (lc($real_checksum) eq lc($name_checksum)) {
+			print("${filename}: $real_checksum - OK!\n");
+			next();
+		}
+        else {
+            print("${filename}: $real_checksum - NOT OK! Should be ${name_checksum}!\n");
+            next();
+        }
+    }
+    else { # can't find checksum in filename, just print filename + generated checksum and let the user do the thinking
+        print("${filename}: $real_checksum\n");
+        next();
+	}
+}
+
+exit(0);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/proxy-loop	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,5 @@
+#!/bin/sh
+while true; do
+  ssh -N localhost
+  sleep 10
+done
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/putcrc.pl	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use String::CRC32;
+
+my @files = @ARGV or print("Usage: ren file1 ... fileN\n") && exit(1);
+my $skip=0;
+foreach (@files) {
+	my $newname = $_;
+	open(FILE,$_);
+	my $crc=sprintf("%08X",crc32(*FILE));
+	close(FILE);
+	$newname =~ s/(.*)\.([^.]*)/$1 [$crc].$2/;
+	$newname =~ s/\] (\[$crc)/]$1/;
+	print(qq($_: $newname already exists, skipping\n)) and next() if -e $newname and $_ ne $newname;
+	if ($_ eq $newname) {
+		print("$_: no need to rename, skipping\n");
+	} else {
+		if($skip==1) { print("$_ --> $newname\n"); }
+		else {
+			if(rename($_, $newname)) { print("$_ -> $newname\n"); }
+			else { print("$_: rename failed"); }
+		}
+	}
+	next();
+}
+
+exit(0);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/smu	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+keyword=$(printf "%s\n" "$*" | tr ' ' '*')
+find /anime/music/ -iname "*${keyword}*"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/statfun	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,8 @@
+#!/bin/sh
+> /tmp/mainlogfun
+while read line; do
+	filename=$(printf "%s" "${line}" | grep OK\ DOWNLOAD | grep -v "^$" | sed -e 's/.*OK DOWNLOAD: Client "[^"]*", "\(.*\)"..*/\1/')
+	basename -- "${filename}" >> /tmp/mainlogfun
+done < /srv/log/vsftpd/main.log
+grep -v "^$" /tmp/mainlogfun > /root/mainlogfun
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/testcrc	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use String::CRC32;
+
+my @files = @ARGV or print("Usage u fail") && exit(1);
+
+foreach(@files) {
+	my $filename = $_;
+	open(FILE,$filename);
+	my $crc=crc32(*FILE);
+	close(FILE);
+	$crc=sprintf("%X",$crc);
+	print("$filename: $crc\n");
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/xkcdmania	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+dir="/anime/misc/webcomics/xkcd"
+[ -d "${dir}" ] || exit 1
+
+fetchlink() {
+  if [ "$1" -a "$2" ]; then
+    wget --quiet -O "$2" "$1"
+  else
+    return 1
+  fi
+}
+latest=$(fetchlink http://xkcd.com/ - | grep 'Permanent link' | sed -e 's/.*\/\([0-9]*\)\/.*/\1/')
+[ -n "${latest}" ] || exit 1
+next=1
+while [ "${next}" -le "${latest}" ]; do
+  to_dl="${to_dl} ${next}"
+  next=$((next + 1))
+done
+
+for i in $to_dl
+do
+  if [ ! -n "$(find "$dir/$(printf '%04d' $i)"* -type f 2>/dev/null)" ] && [ "${i}" -ne 404 ]; then
+    page=$(fetchlink "http://xkcd.com/$i/" -)
+    img=$(echo "$page" | grep 'Image URL' | sed -e 's/.*\(http[^<]*\).*/\1/' | head -n 1)
+    echo "$(echo "$page" | grep "src" | grep "$img" | sed -e 's/.*title="\([^\"]*\)".*/\1/')" > "$dir/$(printf '%04d' $i) $(basename $img | sed -e 's/\(.*\)\..*/\1/').txt"
+    fetchlink "${img}" "$dir/$(printf '%04d' $i) $(basename "$img")"
+  fi
+done
--- a/hg	Sat Oct 29 11:40:03 2011 +0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-[ui]
-username = Edho Prima Arief <edho@myconan.net>
-merge = vimdiff
-verbose = true
-
-[merge-tools]
-vimdiff.executable = vim
-vimdiff.args = -d $base $local $output $other +close +close
-
-[extensions]
-#hgext.convert = 
-#progress =
-
-[hostfingerprints]
-bitbucket.org = 81:2b:08:90:dc:d3:71:ee:e0:7c:b4:75:ce:9b:6c:48:94:56:a1:fe
-
--- a/inputrc	Sat Oct 29 11:40:03 2011 +0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-#Basic settings
-set bell-style none
-set keymap emacs
-
-#Home/End
-#GNOME Terminal
-"\eOH": beginning-of-line
-"\eOF": end-of-line
-#tmux
-"\e[1~": beginning-of-line
-"\e[4~": end-of-line
-
-#Delete
-"\e[3~": delete-char
-
-#Alt-Left/Right
-#GNOME Terminal
-"\e[1;3D": backward-word
-"\e[1;3C": forward-word
-#tmux
-"\e\e[D": backward-word
-"\e\e[C": forward-word
-
-#Up/Down
-"\e[A": history-search-backward
-"\e[B": history-search-forward
-#GNOME Terminal
-"\eOA": history-search-backward
-"\eOB": history-search-forward
-
-#Misc
-"\C-w": unix-filename-rubout
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rc/bash	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,92 @@
+#!/usr/bin/env bash
+
+if [ "${ECOS_BASH_LOADED}" != "yes" ]; then
+  ECOS_BASH_LOADED="yes"
+else
+  return
+fi
+
+[ -f "${HOME}/.ecos_bash.before" ] && . "${HOME}/.ecos_bash.before"
+
+_org_path="${PATH}"
+export PATH="${HOME}/.ecos_bin:${HOME}/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
+
+PS1='[\u@\h \W]\$ '
+#PS1='[\[\e[0;33m\]\u\[\e[0m\]@\[\e[0;32m\]\h\[\e[0m\] \[\e[1;34m\]\W\[\e[0m\]]\$ '
+
+shopt -s histappend
+PROMPT_COMMAND='history -a'
+export HISTFILESIZE=10000
+export HISTCONTROL=ignoredups
+
+export PAGER="less -Rins"
+export EDITOR=vi
+export LANG="en_US.UTF-8"
+unset LS_COLORS
+
+alias less="less -Rins"
+#assuming POSIX grep
+alias fgrep="grep -F"
+alias egrep="grep -E"
+alias ls="ls -F"
+alias rm="rm -i"
+alias rd="rdesktop -g 1280x600 -K -a 16 -z -P -r sound:off -r clipboard:CLIPBOARD -5"
+
+_has_rm_I=
+_has_gnu_ls=
+_has_gnu_grep=
+case "$(uname -s)" in
+  Linux)
+    _has_rm_I=y
+    _has_gnu_ls=y
+    _has_gnu_grep=y
+  ;;
+  SunOS)
+    [ -x /usr/gnu/bin/rm ] && _has_rm_I=y
+    [ -x /usr/gnu/bin/ls ] && _has_gnu_ls=y
+    [ -x /usr/gnu/bin/grep ] && _has_gnu_grep=y
+    [ -d /usr/xpg4/bin ] && PATH="/usr/xpg4/bin:${PATH}"
+    [ -d /opt/csw/bin ] && PATH="/opt/csw/bin:${PATH}"
+    [ -d /opt/csw/sbin ] && PATH="/opt/csw/sbin:${PATH}"
+    [ -d /usr/gnu/bin ] && PATH="/usr/gnu/bin:${PATH}"
+    export PATH
+    alias ping="ping -s"
+    alias ping6="ping -A inet6"
+  ;;
+  FreeBSD)
+    _has_rm_I=y
+    export CLICOLOR=
+    export LSCOLORS=ExGxFxdxCxegedabagExEx
+  ;;
+  OpenBSD)
+    if command -v colorls > /dev/null 2>&1; then
+      export CLICOLOR=
+      alias ls='colorls -F'
+    fi
+  ;;
+  CYGWIN*)
+    export PATH="${PATH}:${_org_path}"
+  ;;
+esac
+
+[ "${_has_rm_I}" = y ] && alias rm="rm -I"
+[ "${_has_gnu_ls}" = y ] && alias ls="ls -F --color=auto"
+[ "${_has_gnu_grep}" = y ] && alias grep="grep --color=auto"
+
+unset _has_rm_I
+unset _has_gnu_ls
+unset _has_gnu_grep
+
+
+case "${TERM}" in
+  xterm*|screen*|dtterm)
+    PROMPT_COMMAND='echo -ne "\033]0;${LOGNAME}@${HOSTNAME}: ${PWD}\007"'
+  ;;
+esac
+
+if command -v vim > /dev/null 2>&1; then
+  alias vi=vim
+  export EDITOR=vim
+fi
+[ -f "${HOME}/.ecos_bash.after" ] && . "${HOME}/.ecos_bash.after"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rc/hg	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,16 @@
+[ui]
+username = Edho Prima Arief <edho@myconan.net>
+merge = vimdiff
+verbose = true
+
+[merge-tools]
+vimdiff.executable = vim
+vimdiff.args = -d $base $local $output $other +close +close
+
+[extensions]
+#hgext.convert = 
+#progress =
+
+[hostfingerprints]
+bitbucket.org = 81:2b:08:90:dc:d3:71:ee:e0:7c:b4:75:ce:9b:6c:48:94:56:a1:fe
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rc/inputrc	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,33 @@
+#Basic settings
+set bell-style none
+set keymap emacs
+
+#Home/End
+#GNOME Terminal
+"\eOH": beginning-of-line
+"\eOF": end-of-line
+#tmux
+"\e[1~": beginning-of-line
+"\e[4~": end-of-line
+
+#Delete
+"\e[3~": delete-char
+
+#Alt-Left/Right
+#GNOME Terminal
+"\e[1;3D": backward-word
+"\e[1;3C": forward-word
+#tmux
+"\e\e[D": backward-word
+"\e\e[C": forward-word
+
+#Up/Down
+"\e[A": history-search-backward
+"\e[B": history-search-forward
+#GNOME Terminal
+"\eOA": history-search-backward
+"\eOB": history-search-forward
+
+#Misc
+"\C-w": unix-filename-rubout
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rc/tcsh	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,104 @@
+#!/usr/bin/env tcsh
+[ -e "${HOME}/.ecos_tcsh.before" ] && source "${HOME}/.ecos_tcsh.before"
+umask 22
+limit coredumpsize 0
+
+set prompt="[%B%n@%m %~%b]%# "
+set path=({,/usr}/{bin,sbin} "${HOME}"/{,.ecos_}bin)
+set history=1000
+set savehist=1000
+set nobeep
+set filec
+
+setenv EDITOR vi
+setenv PAGER less
+setenv BLOCKSIZE K
+setenv LC_COLLATE C
+setenv LANG en_US.UTF-8
+
+unset autologout
+unset autoexpand
+unset autolist
+unset ignoreeof
+
+unalias \*
+alias rd "rdesktop -g 1280x700 -K -a 16 -z -P -r sound:off -r clipboard:CLIPBOARD -5"
+alias h history 25
+alias j jobs -l
+alias la ls -A
+alias ll ls -lA
+alias ls ls -F
+alias rm rm -i
+
+if ($?prompt) then
+  set gnuls_opts="--color=auto --group-directories-first -F"
+  set iscolor=0
+  switch (${TERM})
+    case xterm*:
+    case dtterm:
+    case screen*:
+      setenv CLICOLOR 
+      set myhost=`hostname | cut -d '.' -f 1`
+      set prompt="[%{\033[0;33m%}%n%{\033[0m%}@%{\033[0;32m%}%m%{\033[0m%} %{\033[1;34m%}%c%{\033[0m%}]%# "
+      alias mypwd 'printf "%s\n" "${PWD}" | sed -e "s#^${HOME}#~#"'
+      alias precmd 'printf "\033]0;${USER}@${myhost}: %s\007" "`mypwd`"'
+      set iscolor=1
+    breaksw
+  endsw
+
+  if ("$TERM" == "screen") then
+    bindkey '\e[1~' beginning-of-line
+    bindkey '\e[3~' delete-char
+    bindkey '\e[4~' end-of-line
+    bindkey '\e[5~' history-search-backward
+    bindkey '\e[6~' history-search-forward
+    bindkey '\eOD' backward-word
+    bindkey '\eOC' forward-word
+    bindkey '\e\e[D' backward-word
+    bindkey '\e\e[C' forward-word
+  endif
+  bindkey "^W" backward-delete-word
+  bindkey -k up history-search-backward
+  bindkey -k down history-search-forward
+endif
+
+switch (`uname -s`)
+  case FreeBSD:
+    set path=(${path} /usr/local/{bin,sbin})
+    setenv LSCOLORS ExGxFxdxCxegedabagExEx
+    alias ls ls -FG
+    ( which gnuls ) > /dev/null && alias ls gnuls ${gnuls_opts}
+    alias man man -o
+    alias rm rm -I
+    alias top top -P
+  breaksw
+  case NetBSD:
+    set path=(${path} /usr/pkg/{bin,sbin})
+    breaksw
+  case OpenBSD:
+    set path=(${path} /usr/local/{bin,sbin})
+    setenv LSCOLORS ExGxFxdxCxegedabagExEx
+    [ "${iscolor}" -eq 1 ] && setenv TERM xterm-256color
+    ( which colorls ) > /dev/null && alias ls colorls -FG
+  breaksw
+  case DragonFly:
+    set path=(${path} /usr/pkg/{bin,sbin})
+    setenv LSCOLORS ExGxFxdxCxegedabagExEx
+    alias ls ls -FG
+  breaksw
+  case SunOS:
+    set path=(${path} /usr/{gnu,csw,xpg4}/{bin,sbin})
+    [ -x /usr/gnu/bin/ls ] && alias ls /usr/gnu/bin/ls ${gnuls_opts}
+  breaksw
+  case Linux:
+    alias ls ls ${gnuls_opts}
+    alias grep grep --color=auto
+  breaksw
+endsw
+unset gnuls_opts
+
+( which vim ) > /dev/null && alias vi vim && setenv EDITOR vim
+
+[ -e "${HOME}/.ecos_tcsh.after" ] && source "${HOME}/.ecos_tcsh.after"
+
+[ -x "/usr/games/fortune" ] && "/usr/games/fortune"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rc/tmux	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,29 @@
+##PRE-1.4
+#set -g terminal-overrides '*:acsc@'
+
+##UNDEFINED. NEED CHECK WHICH VERSION
+set -g repeat-time 0
+set -g status-bg blue
+set -g status-fg white
+
+set -g status-left '[#S]'
+set -g status-left-attr bold
+set -g status-left-fg yellow
+
+set -g status-right '#[fg=yellow,bold]#H | %b-%d %H:%M '
+
+set -g status-utf8 on
+setw -g utf8 on
+
+#set -g pane-border-bg black
+#set -g pane-border-fg white
+#set -g pane-active-border-bg black
+set -g pane-active-border-fg blue
+
+set -g set-titles on
+set -g set-titles-string '[#S] #I:#W #T'
+
+setw -g window-status-current-bg red
+setw -g window-status-current-fg white
+setw -g window-status-current-format '#I:#W'
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rc/vim	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,29 @@
+set showmode
+set showcmd
+set nomodeline
+set autoindent
+set lazyredraw
+set vb t_vb=
+set ruler
+set nohls
+set nocompatible
+set backspace=2
+set esckeys
+set noerrorbells
+syntax on
+set ts=2
+set expandtab
+set title
+
+map <C-t><up> :tabr<cr>
+map <C-t><down> :tabl<cr>
+map <C-t><left> :tabp<cr>
+map <C-t><right> :tabn<cr>
+map <C-t>p :tabp<cr>
+map <C-t>n :tabn<cr>
+map <C-t><C-t> :NERDTreeToggle<cr>
+map <C-t><C-m> :NERDTreeMirror<cr>
+
+"autocmd VimEnter * NERDTree
+"autocmd BufEnter * NERDTreeMirror
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rc/zsh	Sat Oct 29 11:40:35 2011 +0700
@@ -0,0 +1,26 @@
+#!/usr/bin/env zsh
+[ -f "${HOME}/.ecos_zsh.before" ] && . "${HOME}/.ecos_zsh.before"
+case $TERM in
+  xterm*|screen*)
+    precmd () {print -Pn "\e]0;%n@%m: %~\a"}
+  ;;
+esac
+PS1='[%n@%m %~]%% '
+export PATH="${HOME}/.ecos_bin:${PATH}"
+HISTFILE=~/.histfile
+HISTSIZE=10000
+SAVEHIST=10000
+setopt appendhistory nomatch
+unsetopt autocd beep extendedglob notify
+bindkey -e
+bindkey '^[[A' history-search-backward
+bindkey '^[[B' history-search-forward
+
+autoload -Uz compinit
+compinit
+
+export EDITOR=vi
+export PAGER='less -Rins'
+alias less='less -Rins'
+alias ls='ls -F'
+[ -f "${HOME}/.ecos_zsh.after" ] && . "${HOME}/.ecos_zsh.after"
--- a/setup	Sat Oct 29 11:40:03 2011 +0700
+++ b/setup	Sat Oct 29 11:40:35 2011 +0700
@@ -1,74 +1,108 @@
 #!/bin/sh
 
-install() {
-  uninstall
-  #create symlinks
-  linker "tcsh" ".ecos_tcsh"
-  linker "bash" ".ecos_bash"
-  linker "zsh" ".ecos_zsh"
-  linker "tmux" ".tmux.conf"
-  linker "hg" ".hgrc"
-  linker "vim" ".vimrc"
-  linker "inputrc" ".inputrc"
-  #originally bin-ec. Renamed to .ecos.bin for sanity when listing home
-  #and replaced . with _ for more sanity
-  linker "bin" ".ecos_bin"
+basedir="`dirname "${0}"`"
+cd "${basedir}"
+basedir="`pwd`"
+rcdir="${basedir}/rc"
+bindir="${basedir}/bin"
+
+test -n "${HOME}" || exit 1
+
+_echo() {
+  _echon "${*}"; printf "\n"
+}
+_echon() {
+  printf "%s" "${*}"
+}
 
-  #modify cshrc
-  echo '[ -r "${HOME}/.ecos_tcsh" ] && source "${HOME}/.ecos_tcsh" #ECCORE_TCSH' >> "${HOME}/.cshrc"
-  #modify bash_profile and bashrc
-  echo '[ -r "${HOME}/.ecos_bash" ] && . "${HOME}/.ecos_bash" #ECCORE_BASH' >> "${HOME}/.bash_profile"
-  echo '[ -r "${HOME}/.ecos_bash" ] && . "${HOME}/.ecos_bash" #ECCORE_BASH' >> "${HOME}/.bashrc"
-  #modify zshrc
-  echo '[ -r "${HOME}/.ecos_zsh" ] && . "${HOME}/.ecos_zsh" #ECCORE_ZSH' >> "${HOME}/.zshrc"
+_tcsh() {
+  case "$1" in
+    uninstall|install)
+      _rc "${1}" "tcsh" ".ecos_tcsh"
+      _init "${1}" '[ -r "${HOME}/.ecos_tcsh" ] && source "${HOME}/.ecos_tcsh" #ECCORE_TCSH' ".cshrc"
+    ;;
+  esac
+}
+
+_bash() {
+  case "$1" in
+    uninstall|install)
+      _rc "${1}" "bash" ".ecos_bash"
+     _init "${1}" '[ -r "${HOME}/.ecos_bash" ] && . "${HOME}/.ecos_bash" #ECCORE_BASH' ".bash_profile"
+     _init "${1}" '[ -r "${HOME}/.ecos_bash" ] && . "${HOME}/.ecos_bash" #ECCORE_BASH' ".bashrc"
+    ;;
+  esac
 }
 
-linker() {
-  echo "Creating symlink: ${1} => ~/${2}"
-  ln -fs "${PWD}/${1}" "${HOME}/${2}"
-}
-
-uninstall_tcsh() {
-  if [ -f "${HOME}/.cshrc" ]; then
-    grep -v '#ECCORE_TCSH' "${HOME}/.cshrc" > .cleancshrc
-    mv .cleancshrc "${HOME}/.cshrc"
-  fi
+_zsh() {
+  case "$1" in
+    uninstall|install)
+      _rc "${1}" "zsh" ".ecos_zsh"
+      _init "${1}" '[ -r "${HOME}/.ecos_zsh" ] && . "${HOME}/.ecos_zsh" #ECCORE_ZSH' ".zshrc"
+    ;;
+  esac
 }
 
-uninstall() {
-  for i in .ecos_tcsh .tmux.conf .hgrc .vimrc .inputrc bin-ec .ecos.bin .ecos_bin .ecos_bash .ecos_zsh; do
-    if [ -f "${HOME}/${i}" ]; then
-      echo "Removing file: ~/${i}"
-      rm -f "${HOME}/${i}"
+_rc() {
+  _srcfile="${rcdir}/${2}"
+  _dstfile="${HOME}/${3}"
+  if test ! -h "${_dstfile}"; then
+    if test -f "${_dstfile}"; then
+      cp "${_dstfile}" "${_dstfile}.bak"
+    elif test -d "${_dstfile}"; then
+      cp -r "${_dstfile}" "${_dstfile}.bak"
     fi
-  done
-  uninstall_tcsh
+    _echo "${_dstfile} backed up to ${_dstfile}.bak"
+  fi
+  rm -f "${_dstfile}"
+  case "${1}" in
+    install)
+      ln -fs "${_srcfile}" "${_dstfile}"
+      _echo "Installed ${_dstfile}"
+    ;;
+    uninstall)
+      _echo "Removed ${_dstfile}"
+    ;;
+  esac
 }
 
-update() {
-  if [ -f "${HOME}/.tcsh_exec" ]; then
-    mv -f "${HOME}/.tcsh_exec" "${HOME}/.ecos_tcsh.after"
-    echo "Moved: ${HOME}/.tcsh_exec => ${HOME}/.ecos_tcsh.after"
+_init() {
+  _script="${HOME}/${3}"
+  _scripttmp="${HOME}/.tmp.${3}"
+  _data="${2}"
+  if [ -f "${_script}" ]; then
+    grep -v "${_data}" "${_script}" > "${_scripttmp}"
+    mv -f "${_scripttmp}" "${_script}"
   fi
+  case "${1}" in
+    install)
+      _echo "${_data}" >> "${_script}"
+      _echo "Added autostart to ${_script}"
+    ;;
+    uninstall)
+      _echo "Removed autostart from ${_script}"
+    ;;
+  esac
 }
 
-help() {
+_help() {
   cat <<EOF
 Usage: ${0} [install|uninstall]
 EOF
 }
 
-case "$1" in
-  install)
-    install
-  ;;
-  uninstall)
-    uninstall
-  ;;
-  update)
-    update
+case "${1}" in
+  install|uninstall)
+    for i in tcsh bash zsh; do
+      _"${i}" "${1}"
+    done
+    _rc "${1}" "tmux" ".tmux.conf"
+    _rc "${1}" "hg" ".hgrc"
+    _rc "${1}" "vim" ".vimrc"
+    _rc "${1}" "inputrc" ".inputrc"
+    _rc "${1}" "bin" ".ecos_bin"
   ;;
   *)
-    help
+    _help
   ;;
 esac
--- a/tcsh	Sat Oct 29 11:40:03 2011 +0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-#!/usr/bin/env tcsh
-[ -e "${HOME}/.ecos_tcsh.before" ] && source "${HOME}/.ecos_tcsh.before"
-umask 22
-limit coredumpsize 0
-
-set prompt="[%B%n@%m %~%b]%# "
-set path=({,/usr}/{bin,sbin} "${HOME}"/{,.ecos_}bin)
-set history=1000
-set savehist=1000
-set nobeep
-set filec
-
-setenv EDITOR vi
-setenv PAGER less
-setenv BLOCKSIZE K
-setenv LC_COLLATE C
-setenv LANG en_US.UTF-8
-
-unset autologout
-unset autoexpand
-unset autolist
-unset ignoreeof
-
-unalias \*
-alias rd "rdesktop -g 1280x700 -K -a 16 -z -P -r sound:off -r clipboard:CLIPBOARD -5"
-alias h history 25
-alias j jobs -l
-alias la ls -A
-alias ll ls -lA
-alias ls ls -F
-alias rm rm -i
-
-if ($?prompt) then
-  set gnuls_opts="--color=auto --group-directories-first -F"
-  set iscolor=0
-  switch (${TERM})
-    case xterm*:
-    case dtterm:
-    case screen*:
-      setenv CLICOLOR 
-      set myhost=`hostname | cut -d '.' -f 1`
-      set prompt="[%{\033[0;33m%}%n%{\033[0m%}@%{\033[0;32m%}%m%{\033[0m%} %{\033[1;34m%}%c%{\033[0m%}]%# "
-      alias mypwd 'printf "%s\n" "${PWD}" | sed -e "s#^${HOME}#~#"'
-      alias precmd 'printf "\033]0;${USER}@${myhost}: %s\007" "`mypwd`"'
-      set iscolor=1
-    breaksw
-  endsw
-
-  if ("$TERM" == "screen") then
-    bindkey '\e[1~' beginning-of-line
-    bindkey '\e[3~' delete-char
-    bindkey '\e[4~' end-of-line
-    bindkey '\e[5~' history-search-backward
-    bindkey '\e[6~' history-search-forward
-    bindkey '\eOD' backward-word
-    bindkey '\eOC' forward-word
-    bindkey '\e\e[D' backward-word
-    bindkey '\e\e[C' forward-word
-  endif
-  bindkey "^W" backward-delete-word
-  bindkey -k up history-search-backward
-  bindkey -k down history-search-forward
-endif
-
-switch (`uname -s`)
-  case FreeBSD:
-    set path=(${path} /usr/local/{bin,sbin})
-    setenv LSCOLORS ExGxFxdxCxegedabagExEx
-    alias ls ls -FG
-    ( which gnuls ) > /dev/null && alias ls gnuls ${gnuls_opts}
-    alias man man -o
-    alias rm rm -I
-    alias top top -P
-  breaksw
-  case NetBSD:
-    set path=(${path} /usr/pkg/{bin,sbin})
-    breaksw
-  case OpenBSD:
-    set path=(${path} /usr/local/{bin,sbin})
-    setenv LSCOLORS ExGxFxdxCxegedabagExEx
-    [ "${iscolor}" -eq 1 ] && setenv TERM xterm-256color
-    ( which colorls ) > /dev/null && alias ls colorls -FG
-  breaksw
-  case DragonFly:
-    set path=(${path} /usr/pkg/{bin,sbin})
-    setenv LSCOLORS ExGxFxdxCxegedabagExEx
-    alias ls ls -FG
-  breaksw
-  case SunOS:
-    set path=(${path} /usr/{gnu,csw,xpg4}/{bin,sbin})
-    [ -x /usr/gnu/bin/ls ] && alias ls /usr/gnu/bin/ls ${gnuls_opts}
-  breaksw
-  case Linux:
-    alias ls ls ${gnuls_opts}
-    alias grep grep --color=auto
-  breaksw
-endsw
-unset gnuls_opts
-
-( which vim ) > /dev/null && alias vi vim && setenv EDITOR vim
-
-[ -e "${HOME}/.ecos_tcsh.after" ] && source "${HOME}/.ecos_tcsh.after"
-
-[ -x "/usr/games/fortune" ] && "/usr/games/fortune"
--- a/tmux	Sat Oct 29 11:40:03 2011 +0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-##PRE-1.4
-#set -g terminal-overrides '*:acsc@'
-
-##UNDEFINED. NEED CHECK WHICH VERSION
-set -g repeat-time 0
-set -g status-bg blue
-set -g status-fg white
-
-set -g status-left '[#S]'
-set -g status-left-attr bold
-set -g status-left-fg yellow
-
-set -g status-right '#[fg=yellow,bold]#H | %b-%d %H:%M '
-
-set -g status-utf8 on
-setw -g utf8 on
-
-#set -g pane-border-bg black
-#set -g pane-border-fg white
-#set -g pane-active-border-bg black
-set -g pane-active-border-fg blue
-
-set -g set-titles on
-set -g set-titles-string '[#S] #I:#W #T'
-
-setw -g window-status-current-bg red
-setw -g window-status-current-fg white
-setw -g window-status-current-format '#I:#W'
-
--- a/vim	Sat Oct 29 11:40:03 2011 +0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-set showmode
-set showcmd
-set nomodeline
-set autoindent
-set lazyredraw
-set vb t_vb=
-set ruler
-set nohls
-set nocompatible
-set backspace=2
-set esckeys
-set noerrorbells
-syntax on
-set ts=2
-set expandtab
-set title
-
-map <C-t><up> :tabr<cr>
-map <C-t><down> :tabl<cr>
-map <C-t><left> :tabp<cr>
-map <C-t><right> :tabn<cr>
-map <C-t>p :tabp<cr>
-map <C-t>n :tabn<cr>
-map <C-t><C-t> :NERDTreeToggle<cr>
-map <C-t><C-m> :NERDTreeMirror<cr>
-
-"autocmd VimEnter * NERDTree
-"autocmd BufEnter * NERDTreeMirror
-
--- a/zsh	Sat Oct 29 11:40:03 2011 +0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-#!/usr/bin/env zsh
-[ -f "${HOME}/.ecos_zsh.before" ] && . "${HOME}/.ecos_zsh.before"
-case $TERM in
-  xterm*|screen*)
-    precmd () {print -Pn "\e]0;%n@%m: %~\a"}
-  ;;
-esac
-PS1='[%n@%m %~]%% '
-export PATH="${HOME}/.ecos_bin:${PATH}"
-HISTFILE=~/.histfile
-HISTSIZE=10000
-SAVEHIST=10000
-setopt appendhistory nomatch
-unsetopt autocd beep extendedglob notify
-bindkey -e
-bindkey '^[[A' history-search-backward
-bindkey '^[[B' history-search-forward
-
-autoload -Uz compinit
-compinit
-
-export EDITOR=vi
-export PAGER='less -Rins'
-alias less='less -Rins'
-alias ls='ls -F'
-[ -f "${HOME}/.ecos_zsh.after" ] && . "${HOME}/.ecos_zsh.after"