view setup @ 100:06ab5f0f9c28

dumpshot: mindlessly dumps shot*.png files produced by mplayer.
author Edho Prima Arief <edho@myconan.net>
date Tue, 19 Jul 2011 15:43:36 +0700
parents 54a82956bb11
children 7c01fc6f7460
line wrap: on
line source

#!/bin/sh

install() {
  uninstall
  #create symlinks
  linker "tcsh" ".ecos_tcsh"
  linker "bash" ".ecos_bash"
  linker "zsh" ".ecos_zsh"
  linker "tmux" ".tmux.conf"
  linker "hg" ".hgrc"
  linker "vim" ".vimrc"
  linker "inputrc" ".inputrc"
  #originally bin-ec. Renamed to .ecos.bin for sanity when listing home
  #and replaced . with _ for more sanity
  linker "bin" ".ecos_bin"

  #modify cshrc
  echo '[ -r "${HOME}/.ecos_tcsh" ] && source "${HOME}/.ecos_tcsh" #ECCORE_TCSH' >> "${HOME}/.cshrc"
  #modify bash_profile and bashrc
  echo '[ -r "${HOME}/.ecos_bash" ] && . "${HOME}/.ecos_bash" #ECCORE_BASH' >> "${HOME}/.bash_profile"
  echo '[ -r "${HOME}/.ecos_bash" ] && . "${HOME}/.ecos_bash" #ECCORE_BASH' >> "${HOME}/.bashrc"
  #modify zshrc
  echo '[ -r "${HOME}/.ecos_zsh" ] && . "${HOME}/.ecos_zsh" #ECCORE_ZSH' >> "${HOME}/.zshrc"
}

linker() {
  echo "Creating symlink: ${1} => ~/${2}"
  ln -fs "${PWD}/${1}" "${HOME}/${2}"
}

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

uninstall() {
  for i in .ecos_tcsh .tmux.conf .hgrc .vimrc .inputrc bin-ec .ecos.bin .ecos_bin .ecos_bash .ecos_zsh; do
    if [ -f "${HOME}/${i}" ]; then
      echo "Removing file: ~/${i}"
      rm -f "${HOME}/${i}"
    fi
  done
  uninstall_tcsh
}

update() {
  if [ -f "${HOME}/.tcsh_exec" ]; then
    mv -f "${HOME}/.tcsh_exec" "${HOME}/.ecos_tcsh.after"
    echo "Moved: ${HOME}/.tcsh_exec => ${HOME}/.ecos_tcsh.after"
  fi
}

help() {
  cat <<EOF
Usage: ${0} [install|uninstall]
EOF
}

case "$1" in
  install)
    install
  ;;
  uninstall)
    uninstall
  ;;
  update)
    update
  ;;
  *)
    help
  ;;
esac