Mercurial > ec-dotfiles
view setup @ 289:c52680b34356
Fixes.
author | Edho Arief <edho@myconan.net> |
---|---|
date | Thu, 12 Jan 2012 10:43:27 +0300 |
parents | 4eeccee282b1 |
children | c6ad8279b076 |
line wrap: on
line source
#!/bin/sh basedir="`dirname "${0}"`" cd "${basedir}" basedir="`pwd`" rcdir="${basedir}/rc" bindir="${basedir}/bin" test -n "${HOME}" || exit 1 _echo() { _echon "${*}"; printf "\n" } _echon() { printf "%s" "${*}" } _tcsh() { case "$1" in uninstall|install) _rc "${1}" "tcsh" ".ecos_tcsh" _init "${1}" 'test -r "${HOME}/.ecos_tcsh" && source "${HOME}/.ecos_tcsh" #ECCORE_TCSH' ".cshrc" ;; esac } _bash() { case "$1" in uninstall|install) _rc "${1}" "bash" ".ecos_bash" _init "${1}" '[ -r "${HOME}/.ecos_bash" ] && . "${HOME}/.ecos_bash" #ECCORE_BASH' ".bash_profile" _init "${1}" '[ -r "${HOME}/.ecos_bash" ] && . "${HOME}/.ecos_bash" #ECCORE_BASH' ".bashrc" ;; esac } _zsh() { case "$1" in uninstall|install) _rc "${1}" "zsh" ".ecos_zsh" _init "${1}" '[ -r "${HOME}/.ecos_zsh" ] && . "${HOME}/.ecos_zsh" #ECCORE_ZSH' ".zshrc" ;; esac } _rc() { if test -z "${3}" || test -z "${2}" || test -z "${1}"; then _echo "Invalid command." return fi _srcfile="${rcdir}/${2}" _dstfile="${HOME}/${3}" if test ! -h "${_dstfile}"; then if test -f "${_dstfile}"; then cp "${_dstfile}" "${_dstfile}.bak" _echo "${_dstfile} backed up to ${_dstfile}.bak" elif test -d "${_dstfile}"; then cp -r "${_dstfile}" "${_dstfile}.bak" _echo "Directory ${_dstfile} backed up to ${_dstfile}.bak" fi fi rm -rf "${_dstfile}" case "${1}" in install) ln -fs "${_srcfile}" "${_dstfile}" _echo "Installed ${_dstfile}" ;; uninstall) _echo "Removed ${_dstfile}" ;; esac } _init() { _script="${HOME}/${3}" _scripttmp="${HOME}/.tmp.${3}" _data="${2}" if [ -f "${_script}" ]; then grep -v "`printf "%s\n" "${_data}" | sed 's/.*#//'`" "${_script}" > "${_scripttmp}" mv -f "${_scripttmp}" "${_script}" fi case "${1}" in install) _echo "${_data}" >> "${_script}" _echo "Added autostart to ${_script}" ;; uninstall) _echo "Removed autostart from ${_script}" ;; esac } _help() { cat <<EOF Usage: ${0} [install|uninstall] EOF } case "${1}" in install|uninstall) for i in tcsh bash zsh; do _"${i}" "${1}" done _rc "${1}" "tmux" ".tmux.conf" _rc "${1}" "hg" ".hgrc" _rc "${1}" "vim" ".vimrc" _rc "${1}" "inputrc" ".inputrc" _rc "${1}" "../bin" ".ecos_bin" ;; *) _help ;; esac