view setup @ 2:1c563df145fa

No need for freakingly fail script uploader.
author Edho Prima Arief <me@myconan.net>
date Sat, 10 Jul 2010 12:12:45 +0000
parents ddd721f10cb8
children 39ef7f7236fc
line wrap: on
line source

#!/bin/sh

install() {
  #create symlinks
  linker "tcsh" ".tcsh_init"
  linker "tmux" ".tmux.conf"
  linker "hg" ".hgrc"

  #modify cshrc
  uninstall_tcsh
  echo '[ -r "${HOME}/.tcsh_init" ] && source "${HOME}/.tcsh_init" #ECCORE_TCSH' >> "${HOME}/.cshrc"
}

linker() {
  ln -fs "${PWD}/${1}" "${HOME}/${2}"
}

uninstall_tcsh() {
  if [ -e "${HOME}/.cshrc" ]; then
    grep -v '#ECCORE_TCSH' "${HOME}/.cshrc" > .cleancshrc
    mv .cleancshrc "${HOME}/.cshrc"
  fi
}

uninstall() {
  for i in .tcsh_init .tmux_conf .hgrc; do
    [ -e "${HOME}/${i}" ] && rm -f "${HOME}/${i}"
  done
  uninstall_tcsh
}

case "$1" in
  install)
    install
  ;;
  uninstall)
    uninstall
  ;;
esac