Skip to content

Instantly share code, notes, and snippets.

@takaokouji
Created April 22, 2013 04:52
Show Gist options
  • Save takaokouji/5432502 to your computer and use it in GitHub Desktop.
Save takaokouji/5432502 to your computer and use it in GitHub Desktop.
#############################
#! Is colorful terminal ?
export COLOR_P
if [ "$TERM" = "dumb" -o "$TERM" = "emacs" -o "$TERM" = "putty" ]; then
COLOR_P="nil"
else # color
COLOR_P="t"
fi
##############################
#! autoload
if [ "$COLOR_P" = "t" ]; then
#! colorful
autoload -U colors
colors
fi
#! ultimate completion
if [ ! "x$TERM" = "xemacs" ]; then
autoload -U compinit
compinit -u
fi
##############################
#! customize prompt
#! left prompt
if [ "$COLOR_P" = "t" ]; then
PS1="%{${fg[blue]}%}%n:%d:%j
%m%(!,#,$)%{${fg[default]}%} " # color %{${fg[color]}%}
else
PS1='%n:%c:%j
%m%(!,#,$) ' # non color
fi
#! right prompt
# if [ "$COLOR_P" = "t" ]; then
# RPS1="%{${fg[blue]}%}[%h]%{${fg[default]}%}" # history n
# else
# RPS1='[%h]' # history n
# fi
RPS1='' # nothing
#RPS1='[%w %T]' # time
#! command correct prompt
#$SPROMPT=correct: '%R' -> '%r' [nyae]?
#if [ "$SHELL" = '/usr/bin/zsh' -o "$SHELL" = '/bin/zsh' ]
#then
# case $TERM in
# rxvt|*term)
# precmd() { print -Pn "\e]0;%m - %~\a" }
# preexec () { print -Pn "\e]0;%m - $1\a" }
# ;;
# esac
#fi
precmd() { }
preexec () { }
# VCS version and branch info in RPROMPT
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git hg bzr
zstyle ':vcs_info:*' formats '(%s:%b)'
zstyle ':vcs_info:*' actionformats '(%s:%b|%a)'
zstyle ':vcs_info:(svn|bzr):*' branchformat '%b:r%r'
zstyle ':vcs_info:bzr:*' use-simple true
autoload -Uz is-at-least
if is-at-least 4.3.10; then
zstyle ':vcs_info:git:*' check-for-changes true
zstyle ':vcs_info:git:*' stagedstr "+"
zstyle ':vcs_info:git:*' unstagedstr "-"
zstyle ':vcs_info:git:*' formats '(%s:%b) %c%u'
zstyle ':vcs_info:git:*' actionformats '(%s:%b|%a) %c%u'
fi
##############################
#! zstyle
#! don't differentiation upcase and downcase completion
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
#! color completion
if [ "$COLOR_P" = "t" ]; then
# Linux
#eval `dircolors`
LS_COLORS='di=00;36:'
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
fi
##############################
#! keybing
# emacs
bindkey -e
# vi
#bindkey -v
##############################
#! extented function
#! logout Control-D
setopt IGNORE_EOF
setopt HIST_IGNORE_DUPS
setopt HIST_REDUCE_BLANKS
setopt HIST_IGNORE_SPACE
setopt HIST_NO_STORE
setopt SHARE_HISTORY
setopt PRINT_EIGHT_BIT
setopt INTERACTIVE_COMMENTS
setopt NUMERIC_GLOB_SORT
#preexec () {
# [[ -t 1 ]] || return
# case $TERM in
# (*xterm*|screen|rxvt|(dt|k|E)term) print -Pn "\e]2;[%~] $1\a"
# ;;
# esac
#}
#precmd () {
# [[ -t 1 ]] || return
# case $TERM in
# #(*xterm*|screen|rxvt|(dt|k|E)term) print -Pn "\e]2;${TTY}:$$:%n@%m:%~\a"
# (*xterm*|screen|rxvt|(dt|k|E)term) print -Pn "\e]0;%n@%m:%~\a"
# ;;
# esac
#}
path=(
$HOME/local/sbin
$HOME/local/bin
/sbin
/bin
/usr/sbin
/usr/bin
/usr/local/sbin
/usr/local/bin
/usr/X11R6/bin
)
export EDITOR=vi
#export LESS='--buffers=512 --quit-if-one-screen --LONG-PROMPT'
export LESS='--LONG-PROMPT'
export LESSCHARSET=ascii
export JLESSCHARSET=japanese-euc
export PAGER=less
export GZIP=-9
export BZIP2=-9
export CVS_RSH=ssh
export PERL_BADLANG=
export G_FILENAME_ENCODING=UTF-8
export G_BROKEN_FILENAMES=UTF-8
# OSX
alias ls='ls -G -h'
alias dir='ls -G'
alias stuffit='open -a StuffIt\ Expander'
alias ooffice='open -a OpenOffice.org.app'
alias preview='open -a Preview.app'
alias emacs='/Applications/Emacs.app/Contents/MacOS/Emacs'
alias g.='git add -u && git commit -m .'
alias df='LANG=C df'
# Linux
if [ "$COLOR_P" = "t" ]; then
alias ls='ls --color=auto -h'
alias dir='ls --color=auto --format=vertical'
alias vdir='ls --color=auto --format=long'
else
alias ls='ls -h'
alias dir='ls --format=vertical'
alias vdir='ls --format=long'
fi
#alias rm='$HOME/local/bin/trash'
alias j='jobs -l'
alias sl=ls
alias llh='ls -lhF'
alias ll='ls -lF'
alias lf='ls -F'
alias la='ls -aF'
#alias svn='LC_ALL=C svn'
alias iv='vi -R'
if which jless >& /dev/null
then
alias less='jless -n'
else
alias less='less -n'
fi
# backup files display and remove command
alias chkbackups='/usr/bin/find . -maxdepth 1 -name "?*~" -o -name "?*.bak" -o -name ".[^.]?*~" -o -name ".[^.]?*.bak"'
alias rmbackups='chkbackups | xargs rm'
fignore=(.o \~)
WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'
HISTFILE=$HOME/.zsh_history
HISTSIZE=99999
SAVEHIST=99999
LISTMAX=0
APPENDHISTORY=
[ -e $HOME/.login ] && . $HOME/.login
umask 022
export WHOIS_SERVER=whois.jp
#export GTAGSLABEL=rtags
############################################################
# completion
# Rake
# http://weblog.rubyonrails.org/2006/03/09/fast-rake-task-completion-for-zsh/
_rake_does_task_list_need_generating () {
if [[ ! -f .rake_tasks ]]; then return 0;
else
return $([[ Rakefile -nt .rake_tasks ]])
fi
}
_rake () {
if [[ -f Rakefile ]]; then
if _rake_does_task_list_need_generating; then
echo "\nGenerating .rake_tasks..." >&2
rake --silent --tasks | cut -d " " -f 2 >| .rake_tasks
fi
compadd $(<.rake_tasks)
fi
}
compdef _rake rake
_cap () {
`cap -T | grep '^cap ' | sed 's/^cap //' | sed 's/ .*//' | sed 's/^/compadd /'`
}
compdef _cap cap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment