###################################################################
#  Plamo Linux 桼ե륵ץ for bash
#                            Time-stamp: <2005-02-02 20:09:17 cyamauch>

## ʳ (󥷥Ǥʤ) ǡ
## åξ˼¹Ԥޤ

if [ ! -n "$SSH_CLIENT" -o -n "$SSH_TTY" ] ; then

# ѿ (ܺ٤ man bash)
# ¸ιԿ
HISTSIZE=512
HISTFILESIZE=512
# ʸǻϤޤԡκǸιԤ˥ޥåԤ
# ʤ
HISTCONTROL=ignoreboth
# Ctrl+D  3 ̵뤹
IGNOREEOF=3

# üˤäܸɽ/ʤڤؤ
#if [ "$TERM" = "linux" ] ; then
#  LANG=C
#else
#  LANG=ja_JP.eucJP
#fi
LANG=ja_JP.eucJP
export LANG

# JISɽǤʤüEUCˤ
if [ "$TERM" = "xterm" -o "$TERM" = "dtterm" ] ; then
  JLESSCHARSET=japanese-euc
fi

# less ǹֹĤλ˲̤Ĥ
LESS='-M -X'

EDITOR='vi'
#EDITOR='emacs -nw'
PAGER='less'
export LESS EDITOR PAGER

# if [ $SHLVL = 1 ] ; then
#   PATH="$PATH:." ;
# fi

# ls ǿĤ
#  ~/.dir_colors
if which dircolors >& /dev/null; then
  eval `dircolors -b $HOME/.dir_colors`
  LS_OPTIONS='--color=auto -F -T 0 -N'
else
  LS_OPTIONS='-F -T 0 -N';
fi
# Emacs ʤɤ dumb üǤϿĤʤ
if [ "$TERM" = "dumb" ] ; then
  LS_OPTIONS="-F -T 0 -N --color=none"
else
  GREP_OPTIONS="--color=auto"
  export GREP_OPTIONS
fi
export LS_OPTIONS

alias ls='ls $LS_OPTIONS'
alias dir='dir $LS_OPTIONS';
alias vdir='vdir $LS_OPTIONS';

# WindowΥȥС˥ȥǥ쥯ȥ
# ɽԲǽʾΥץץ
PS1='\u@\h:\w\$ '
#PS1='\h:\w\$ '

# üΥȥ prompt ɽ
if [ "$TERM" = "screen" ] ; then
  SCREEN=screen@
fi
case $TERM in
kterm|xterm|rxvt|dtterm|vt100|screen)
    # WindowΥȥС˥ȥǥ쥯ȥ
    # ɽǽʾΥץץ
    #   ɽ㢪 hoge@host:/usr/X11R7/lib/X11/app-defaults$ _
    PS1='\u@\h:\w\$ '
    #   ɽ㢪 hoge@host:app-defaults$ _
    #PS1='\u@\h:\W\$ '
    HN="$SCREEN`hostname`:"
    #HN="$SCREEN`hostname -s`:"
    case "$TERM" in
    vt*)
	HN=""
    ;;
    esac
    function mkrmhmpwd () {
	tty > /dev/null
	if [ "$?" = "0" ] ; then
	  BSBS_HOME=`echo "/$HOME"|/usr/bin/sed -e 's/\//\\\\\//g'` ;
	  RMHMPWD=`echo "/$PWD"|/usr/bin/sed -e "s/$BSBS_HOME/~/g"` ;
	  if [ "$RMHMPWD" = "/$PWD" ] ; then
	      RMHMPWD="$PWD"
	  fi
	fi
    }
    # ٤ޥǤϤ
    # function mkrmhmpwd () { RMHMPWD="$PWD" ; }
    function termtitle () {
	tty > /dev/null
	if [ "$?" = "0" ] ; then
	  if [ -w `tty` ] ; then
	    echo -ne "\033]0;$TERM - $*\007" > `tty`
	  fi
	fi
    }
    function cd () {
	if [ "x.$*" = "x." ] ; then
	    builtin cd $* ;
	else
	    builtin cd "$*" ;
	fi
	mkrmhmpwd ; termtitle "$HN""[$RMHMPWD]" ;
    }
    function popd () {
	if [ "x.$*" = "x." ] ; then
	    builtin popd $* ;
	else
	    builtin popd "$*" ;
	fi
	mkrmhmpwd ; termtitle "$HN""[$RMHMPWD]" ;
    }
    function pushd () {
	if [ "x.$*" = "x." ] ; then
	    builtin pushd $* ;
	else
	    builtin pushd "$*" ;
	fi
	mkrmhmpwd ; termtitle "$HN""[$RMHMPWD]" ;
    }
    #function pwd () { builtin pwd ; mkrmhmpwd ; termtitle "$HN""[$RMHMPWD]" ; }
    function su () { mkrmhmpwd ; termtitle "$HN""su $*($RMHMPWD)" ;
	if [ "$1" = "-c" ] ; then command su -c "$2";
	elif [ "$2" = "-c" ] ; then command su $1 -c "$3" 
	elif [ "$3" = "-c" ] ; then command su - $2 -c "$4"
	else command su $* ; fi
	mkrmhmpwd ; termtitle "$HN""[$RMHMPWD]" ; }
    function rsh () {
	termtitle "$HN""rsh $*" 
	command rsh $* 
	mkrmhmpwd ; termtitle "$HN""[$RMHMPWD]"
    }
    function rlogin () { 
	termtitle "$HN""rlogin $*" 
	command rlogin $* 
	mkrmhmpwd ; termtitle "$HN""[$RMHMPWD]" 
    }
    function telnet () { 
	termtitle "$HN""telnet $*" 
	command telnet $* 
	mkrmhmpwd ; termtitle "$HN""[$RMHMPWD]"
    }
    function ssh () { 
	termtitle "$HN""ssh $*" 
	command ssh $* 
	mkrmhmpwd ; termtitle "$HN""[$RMHMPWD]"
    }
    function screen () {
	command screen $*
	mkrmhmpwd ; termtitle "$HN""[$RMHMPWD]"
    }
#    mkrmhmpwd ; termtitle "$HN""[$RMHMPWD]"
;;
esac

# üˤBackSpaceĴ
stty erase '^?'
case "$TERM" in
kterm|sun)
    stty erase '^H'
#   ~/.inputrc 
#   bind '"\C-?": delete-char' 
    ;;
#vt*)
#    stty erase '^H'
#    bind '"\C-?": delete-char' 
#    ;;
esac
stty werase '^W'
# Ctrl+S Ǥ stop 
stty stop undef

# Х .inputrc ⻲ȤƤ

#Aliases
alias h='history'
alias rmdvi='rm *.dvi ; rm *.log ; rm *.aux ; rm *.toc'
alias rmback='rm *~ ; rm *.bak'
alias j='jobs -l'
alias la='ls -a'
alias ll='ls -l'
alias z='suspend'
alias x='exit'
alias LS='ls -alF | command less -E'
alias mu='mule -rv'
#alias ssh1='ssh -1'
#alias scp1='scp -oProtocol=1'
#alias xv='xv -nolimits'

fi

# Source global definitions
if [ -f /etc/bashrc ] ; then
  . /etc/bashrc
fi
