# @(#)Cshrc 1.6 91/09/05 SMI

#setenv RSH ssh

umask 027

#################################################################
#
#         .cshrc file
#
#         initial setup file for both interactive and noninteractive
#         C-Shells
#
#################################################################

#eval `dircolors`
#if ($?LS_COLORS) then
#  setenv LS_COLORS "${LS_COLORS}"':*.tar=01;31:*.tgz=01;31:*.rar=01;31:*.bz2=01;31:*.rz=01;31:*.squashfs=01;31:*.md5=00;31:*.par=00;31:*.par2=00;31:*.sfv=00;31:*.iso=00;31:*.udf=00;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.7z=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:'
#else
#  setenv LS_COLORS ':no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:ex=01;32:*.btm=01;32:*.tar=01;31:*.tgz=01;31:*.rar=01;31:*.bz2=01;31:*.rz=01;31:*.squashfs=01;31:*.md5=00;31:*.par=00;31:*.par2=00;31:*.sfv=00;31:*.iso=00;31:*.udf=00;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.7z=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.jpg=01;35:*.png=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:'
#endif

if -e /etc/DIR_COLORS then
  if -e ~/.dir_colors then
    eval `( dircolors -p ; cat ~/.dir_colors ) | dircolors --csh -`
  endif
else
  setenv LS_COLORS ':no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:ex=01;32:*.btm=01;32:*.tar=01;31:*.tgz=01;31:*.rar=01;31:*.bz2=01;31:*.rz=01;31:*.squashfs=01;31:*.md5=00;31:*.par=00;31:*.par2=00;31:*.sfv=00;31:*.iso=00;31:*.udf=00;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.7z=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.jpg=01;35:*.png=01;35:*.gif=01;35:*.bmp=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:'
endif

  
setenv LS_OPTIONS "--color=tty -F -T 0"
setenv EDITOR vi

###---------->command line editor/misc<----------
### Configuration of the command line editor
#set edit
unset wordchars
unset verbose echo
set echo_style = both
set inputmode = insert
set nonomatch

###---------->completion/misc<----------
### Configuration on filename completion
set addsuffix
set fignore = (\
)
unset autolist
unset recexact
set autoexpand
unset matchbeep
unset recognize_only_executables
unset listmaxrows
unset listmax
set notify

setenv HOSTNAME `hostname`
#setenv DOMAINNAME `dnsdomainname`
#if ($DOMAINNAME == "sanitarium.net") setenv PRINTER squirtgun
setenv XNLSPATH /usr/local/bin/nls
#set watch = (1 any any)
set history=200
set user=`whoami`

if ($RunningShell == "tcsh") then
  # all of this stuff is tcsh specific and doesn't work under csh
  source $SourceHome/.os/completes

  # set my fancy prompt and umask
  if ($user != "root") then
    umask 027
    set prompt="%n@%m[%~%]> "
  else
    umask 022
    set prompt="%m %~# "
    #if ($type == "Linux") unlimit stacksize
  endif
  if ($?TERM) then
    if ($TERM == "xterm" || ($TERM == "xterm-256color") || $TERM == "linux" || $TERM == "vt220" || $TERM == "vt102" || $TERM == "Eterm" || $TERM == "dtterm" || $TERM == "ansi" || $TERM == "rxvt" || $TERM == "xterm-kitty") then
      if ($user == "root") then
        #set prompt="%{\033]0;%m\007%}%{[0;40;36m%}%m %~%{[0;31m%}#%{[0;37m%} "
        set prompt="%{\033]0;%m\007%}%{^[[0;40;36m%}%m %{^[[0;34m%}%~%{^[[0;31m%}#%{^[[0;37m%} "
      else
        #set prompt="%{\033]0;%m\007%}%{[0;40;31m%}%n%{[0;35m%}@%{[0;36m%}%m%{[0;35m%}[%{[1;34m%}\!%%%{[0;35m%}]>%{[0;37m%} "
        #set prompt="%{\033]0;%m\007%}%{[0;40;31m%}%n%{[0;35m%}@%{[0;36m%}%m%{[0;35m%}[%{[1;34m%}%~%%%{[0;35m%}]>%{[0;37m%} "
        set prompt="%{\033]0;%m\007%}%{^[[0;40;31m%}%n%{^[[0;35m%}@%{^[[0;36m%}%m%{^[[0;35m%}[%{^[[1;34m%}%~%%%{^[[0;35m%}]>%{^[[0;37m%} "
      endif
    endif
  endif

  #make the arrow key behavior a bit more intelligent
  bindkey -k up history-search-backward
  bindkey -k down history-search-forward
  # make standard editing keys do standard things
  bindkey    ^[[2~  overwrite-mode
  bindkey    ^[[3~  delete-char
  bindkey    ^[[1~  beginning-of-line
  bindkey    ^[[4~  end-of-line
else
  # give me a decent but lame prompt if I am stuck in csh
  if ($user == "root") then
    set prompt="${HOSTNAME}# "
  else
    set prompt="${user}@${HOSTNAME}% "
  endif
endif

set filec
unset autologout
unset notify

alias h             'history'
alias             'stty erase ^H'
alias             'stty erase ^?'
alias k             'd ~/dl/'
alias jbs           'ps -xau | grep $user'
alias cd            'cd \!*;pwd'
alias cp            'cp -i'
alias mv            'mv -i'
alias t             'setenv TERM vt102'
alias d             'ls -lF'
alias D             'ls -AlF'
alias cls           'clear'
alias help          'man'
alias fix           'reset ; /bin/echo -e \\033c'

if -e /usr/bin/vim then
  alias vi '/usr/bin/vim'
  setenv EDITOR /usr/bin/vim
endif

# detect color capable grep and activate it...
unalias grep
echo x | `which grep` --color=auto x >& /dev/null && set GrepColor="Y" || set GrepColor="N"
if ($GrepColor == "Y") then
  alias grep "`which grep` --color=auto"
endif

# determine root's shell so su can run my shell.
if ($user != "root") then
  set RootShell=`grep ^root: /etc/passwd | awk -F/ '{print $NF}'`
  if ($RootShell != "tcsh") then
    set Su=`which su`
    set Tcsh=`which tcsh`
    #if ( -e /usr/bin/emerge ) then
      ## we are on Gentoo with its screwy su.
      #alias su "$Su -c $Tcsh"
    #else
      ## we are on something other than Gentoo
      alias su "$Su -s $Tcsh"
    #endif
  endif
endif

limit coredumpsize 0
