Commits

raichoo committed ba47ea1

added git support to ksh

Comments (0)

Files changed (5)

+[core]
+	editor = vim
+	pager  = less
+[merge]
+	tool = vimdiff
+[color]
+	ui     = true
+	status = auto
+	branch = auto
+	diff   = auto
+	log    = auto
+[alias]
+	tip        = "log --all -n 1 --summary"
+	id				 = "log -n 1 HEAD"
+	refresh    = "fetch --all"
+	transplant = "cherry-pick"
+	continue   = "rebase --continue"
+	abort      = "rebase --abort"
+	skip       = "rebase --skip"
+	amend      = "commit --amend"
+	manifest   = "ls-files"
+	unstage		 = "reset HEAD"
+	forget		 = "rm --cached"
+	rollback	 = "reset --hard"
+	parents		 = "branch --merged"
+	filter		 = "!f() { git filter-branch --tree-filter \"rm -f $1\" HEAD; }; f"
+	restore		 = "checkout head --"
+	serve			 = "!git daemon --reuseaddr --verbose  --base-path=. --export-all ./.git"
+	browse		 = "ls-remote"
+	refs			 = "show-ref -h"
+	branches	 = "branch -a -v"
+	remotes		 = "remote -v"
+	tags			 = "tag"
+	graph			 = "log --graph --pretty=oneline --abbrev-commit --decorate --all"
+	out				 = "log --stat HEAD --not"
+	in				 = "!f() { git log --stat $1 --not HEAD; }; f"
 
 [defaults]
 backout = --merge
-transplant = --log
-diff = --color=always
+import = --no-commit
+
+[alias]
+nudge    = push --rev .
+collapse = rebase --collapse
+shelves  = shelve -l
 
 [extensions]
-hgext.color =
+hgext.progress =
+hgext.rebase =
+hgext.pager = 
+hgext.color = 
 hgext.purge =
 hgext.graphlog =
 hgext.record =
 hgext.transplant =
 hgext.bookmarks = 
 hgext.zeroconf = 
+hgext.mq = 
+hggit =
+hgshelve =
 
 [diff]
 git = True
+
 
 export HOSTNAME=$(hostname | cut -d. -f1)
 export EDITOR='vim'
-export PAGER='less'
+export PAGER='/usr/bin/less'
 export LESS='FSRX'
 export VISUAL='vim'
 export HISTEDIT='vim'
-export HISTFILE="${HOME}/.histfile.$(tty | cut -d/ -f 3)"
+export HISTFILE="$HOME/.histfile.$(tty | cut -d/ -f 3)"
 export UNAME=$(uname)
 export USER=$(whoami)
 export MAINPROMPT='> '
 export SHELLMODE='ksh'
-export HGROOT=''
+export VCSROOT=''
 
 if [[ $UNAME == "Darwin" || $UNAME == "SunOS" || $UNAME == "Linux" ]]
 then
 	if [[ $UNAME == "Linux" ]]
 	then
 		NORM=$(tput op;tput sgr0) && return
+	elif [[ $UNAME == "SunOS" ]]
+	then
+		NORM=$(tput op;tput setab 0;tput setaf 9)
 	else
 		NORM=$(tput op)
 	fi
 		then
 			print "${RED}${HGOUTPUT[0]}${NORM}@${CYAN}${HGOUTPUT[1]}" && return
 		else
-			if [[ "${HGOUTPUT[0]}" == "$(head -n 1 ${HGROOT}/.hg/tags.cache | awk '{ print $1 }')" ]]
+			if [[ "${HGOUTPUT[0]}" == "$(head -n 1 ${VCSROOT}/.hg/tags.cache | awk '{ print $1 }')" ]]
 			then
 				print "${GREEN}${HGOUTPUT[0]}${NORM}@${CYAN}${HGOUTPUT[1]}" && return
 			else
 				print "${YELLOW}${HGOUTPUT[0]}${NORM}@${CYAN}${HGOUTPUT[1]}" && return
 			fi
 		fi
+	elif [[ $SHELLMODE == "git" ]]
+	then
+		GITSTATUS=$(git status -s)
+		GITBRANCH=$(git branch --no-color 2> /dev/null | egrep --color=never '^\*')
+		GITREV=$(git show-ref -h HEAD 2> /dev/null) 
+		if [[ ${GITBRANCH:2} == "(no branch)" ]]
+		then
+			GITBRANCH=${RED}${GITBRANCH:2}
+		else
+			GITBRANCH=${CYAN}${GITBRANCH:2}
+		fi
+		if [[ $(echo $GITSTATUS | egrep '^ ?[M|A|R]') != "" ]]
+		then
+			print "${RED}${GITREV:0:7}${NORM}@${GITBRANCH}" && return
+		else
+			if [[ ${GITREV:0:40} == $(git log --no-color --pretty=oneline --all -n 1 | cut -d ' ' -f1) ]]
+			then
+				print "${GREEN}${GITREV:0:7}${NORM}@${GITBRANCH}" && return
+			else
+				print "${YELLOW}${GITREV:0:7}${NORM}@${GITBRANCH}" && return
+			fi
+		fi
 	fi
 }
 
 function _cd {
 	cd "$@"
-	if [[ $SHELLMODE == "hg" ]]
+	if [[ "${PWD#${VCSROOT}}" == $PWD ]]
 	then
-		if [[ "${PWD#${HGROOT}}" == ${PWD} ]]
-		then
-			mode ksh && return
-		fi
+		mode ksh && return
 	fi
 }
 
-function _vim {
-	open -a MacVim "$@"
-}
-
-function _hg {
-	case $1 in
-		log|diff|manifest|annotate|incoming|outgoing)
-		hg "$@" | less
-		return
-		;;
-	esac
-	hg "$@"
-}
-
-function _cp {
-	if [[ $SHELLMODE == "hg" ]]
-		then
-			_hg copy "$@" && return
-			fi
-			/bin/cp "$@"
-}
-
 function _mv {
-	if [[ $SHELLMODE == "hg" ]]
-		then
-			_hg rename "$@" && return
-			fi
-			/bin/mv "$@"
+	case $SHELLMODE in
+		hg)
+			hg rename "$@" && return
+			;;
+		git)
+			git mv "$@" && return
+			;;
+		esac
 }
 
 function _rm {
-	if [[ $SHELLMODE == "hg" ]]
-		then
-			_hg remove "$@" && return
-			fi
-			/bin/rm "$@"
+	case $SHELLMODE in
+		hg)
+			hg remove "$@" && return
+			;;
+		git)
+			git rm "$@" && return
+			;;
+		esac
 }
 
 function mode {
 	if [[ $# == 0 || $1 == '-h' ]]
 	then
-		print "usage: mode [ksh|hg]"
+		print "usage: mode [ksh|hg|git]"
 	fi
 	case $1 in
 		ksh)
+			unalias cd
+			unalias rm
+			unalias mv
 			export SHELLMODE="ksh"
-			export HGROOT=""
-			export PS1=${MAINPROMPT} && return
+			export VCSROOT=""
+			export PS1=$MAINPROMPT && return
 			;;
 		hg)
+			alias cd='_cd'
+			alias rm='_rm'
+			alias mv='_mv'
 			export SHELLMODE="hg"
-			export HGROOT="$(hg root 2> /dev/null)"
-			if [[ ${HGROOT} == "" ]]
+			export VCSROOT="$(hg root 2> /dev/null)"
+			if [[ $VCSROOT == "" ]]
 			then
 				mode ksh && return
 			fi
 			export PS1='${PURPLE}☿${NORM}:${BOLD}$(_checkrevision)${NORM}:${BLUE}$(_checkdir)${NORM}> '
 			;;
+		git)
+			export SHELLMODE="git"
+			TMPROOT="./$(git rev-parse --show-cdup 2> /dev/null)"
+			if [[ $TMPROOT == "./" ]]
+			then
+				if [ ! -d .git ]
+				then
+					mode ksh && return
+				fi
+			fi
+			TMPBUFFER=$PWD
+			cd $TMPROOT
+			export VCSROOT=$PWD
+			cd $TMPBUFFER
+			alias cd='_cd'
+			alias mv='_mv'
+		  alias rm='_rm'
+			export PS1='${PURPLE}±${NORM}:${BOLD}$(_checkrevision)${NORM}:${BLUE}$(_checkdir)${NORM}> '
 	esac
 }
 
 		else
 			history -l $* && return
 		fi
+	elif [[ $1 == "-s" ]]
+	then
+		grep -a --color=always -- $2 $HOME/.histfile.* | cut -d: -f2 2> /dev/null 
 	else
 		fc $* && return
 	fi
 
 if [[ $USER == "root" ]]
 then
-	USERCOL=${RED} 
+	USERCOL="$RED" 
 else
-	USERCOL=${GREEN}
+	USERCOL="$GREEN"
 fi
 
-source $HOME/.kshsystemrc
+source $HOME/.kshsystemrc.sh
 
 export MAINPROMPT='${NORM}\[${USERCOL}${USER}${NORM}\@${HOSTCOL}${HOSTNAME}${NORM}\:${BLUE}$(_checkdir)${NORM}]\:${RED}${HISTCMD}${NORM}\> '
-export PS1=${MAINPROMPT}
+export PS1=$MAINPROMPT
      
 alias !!='_commandhist'
-alias cd='_cd'
-alias vi='_vim'
-alias vim='_vim'
-alias hg='_hg'
-alias rm='_rm'
-alias cp='_cp'
-alias mv='_mv'
 if [[ $UNAME == "Darwin" ]]
 then
-	export GOROOT="${HOME}/Projects/Packages/go"
-	export GOARCH="amd64"
-	export GOOS="darwin"
-	export GOBIN="${HOME}/.local/bin"
 
-	export HOSTCOL=${YELLOW}
+	function sockstat {
+		if [[ $# == 0 ]]
+		then
+			lsof -i -P
+		else
+			lsof -i -P | grep -i $1
+		fi
+	}
 
-    alias ls='ls -FG'
-    alias pkill='killall'
-    alias pgrep='ps -A | grep -i'
-    alias grep='grep --color=always'
+  export HOSTCOL=${YELLOW}
+	export PATH="$PATH:/Developer/usr/bin:/Users/raichoo/.local/opt/scala/bin:/usr/local/Trolltech/Qt-4.6.patched-carbon/bin"
+
+	alias pfexec='sudo'
+	alias pfksh='sudo ksh'
+	alias clojure="java -cp $HOME/.local/opt/clojure/jline\-0_9_5.jar:$HOME/.local/opt/clojure/clojure.jar jline.ConsoleRunner clojure.main"
+	alias ls='ls -FG'
+	alias pkill='killall'
+	alias pgrep='ps -A | grep -i'
+	alias grep='grep --color=always'
 	alias egrep='egrep --color=always'
 	alias sage='/Applications/sage/sage'
 elif [[ $UNAME == "SunOS" ]]
 
 	export HOSTCOL=${CYAN}
 
-    export PYTHONPATH="${HOME}/.local/lib/python2.4/site-packages"
-    export PATH='${HOME}/.local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/opt/SunStudioExpress/bin:$PATH'
+	export PYTHONPATH="${HOME}/.local/lib/python2.4/site-packages"
+	export PATH='${HOME}/.local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/opt/SunStudioExpress/bin:$PATH'
 	export MANPATH='/usr/share/man:/opt/SunStudioExpress/man:/usr/X11/share/man:/usr/gnu/share/man'
 
-    alias ls='ls -F --color="always"'
+	alias ls='ls -F --color="always"'
 elif [[ $UNAME == "DragonFly" ]]
 then
 	export HOSTCOL=${PURPLE}
 
-    alias ls='ls -FG'
-    alias pkill='killall'
-    alias grep='grep --color=always'
-    alias pgrep='ps -A | grep -i'
+	alias ls='ls -FG'
+	alias pkill='killall'
+	alias grep='grep --color=always'
+	alias pgrep='ps -A | grep -i'
 elif [[ $UNAME == "FreeBSD" ]]
 then
 	export HOSTCOL=${BOLD}${RED}
 
-    alias ls='ls -FG'
-    alias pkill='killall'
-    alias grep='grep --color=always'
-    alias pgrep='ps -A | grep -i'
+	alias ls='ls -FG'
+	alias pkill='killall'
+	alias grep='grep --color=always'
+	alias pgrep='ps -A | grep -i'
 elif [[ $UNAME == "Linux" ]]
 then
 	export HOSTCOL=${BOLD}${GREEN}
 
 	alias ls='ls --color=always'
-    alias grep='grep --color=always'
+	alias grep='grep --color=always'
 	alias egrep='egrep --color=always'
 fi
+
+alias vi='vim'
 set t_kr=OC
 set t_kl=OD
 syntax on
+filetype on
+filetype plugin indent on
 set ruler
 set showcmd
 set showmode
-set shiftwidth=4
-set tabstop=4
+set shiftwidth=2
+set tabstop=2
 set backspace=2
 set hlsearch
-set smartindent
 set number
 set encoding=utf-8
 
 
 if !exists("autocommand_loaded")
 	let autocommand_loaded = 1
-	au BufRead,BufNewFile *.py,*.hs set expandtab
-	au BufRead,BufNewFile *.py,*.hs match BadWhitespace /\s\+$/
-	au BufRead,BufNewFile *.py,*.hs match BadWhitespace /^\s*\t\+/
+	au BufNewFile,BufRead *.d setf dtrace
+	au BufRead,BufNewFile *.py,*.hs,*.yml set expandtab
+	au BufRead,BufNewFile *.py,*.hs,*.yml match BadWhitespace /\s\+$/
+	au BufRead,BufNewFile *.py,*.hs,*.yml match BadWhitespace /^\s*\t\+/
 endif
-