Mercurial > ec-dotfiles
comparison setup @ 325:795ad57794a6
[setup] Returning solaris compatibility.
author | Edho Arief <edho@myconan.net> |
---|---|
date | Sun, 18 Mar 2012 16:02:08 +0700 |
parents | c6ad8279b076 |
children | db66d53e10ea |
comparison
equal
deleted
inserted
replaced
324:391f2b64900e | 325:795ad57794a6 |
---|---|
1 #!/bin/sh | 1 #!/bin/sh |
2 | |
3 set -u | |
4 set -e | |
2 | 5 |
3 basedir="`dirname "${0}"`" | 6 basedir="`dirname "${0}"`" |
4 cd "${basedir}" | 7 cd "${basedir}" |
5 basedir="`pwd`" | 8 basedir="`pwd`" |
6 rcdir="${basedir}/rc" | 9 rcdir="${basedir}/rc" |
48 _echo "Invalid command." | 51 _echo "Invalid command." |
49 return | 52 return |
50 fi | 53 fi |
51 _srcfile="${rcdir}/${2}" | 54 _srcfile="${rcdir}/${2}" |
52 _dstfile="${HOME}/${3}" | 55 _dstfile="${HOME}/${3}" |
53 _dstdir="${_dstfile%/*}" | 56 _dstdir="`_echo "${_dstfile}" | sed -e 's,^\(.*\)/[^/]*$,\1,'`" |
54 mkdir -p "${_dstdir}" | 57 mkdir -p "${_dstdir}" |
55 if test ! -h "${_dstfile}"; then | 58 if test ! -h "${_dstfile}"; then |
56 if test -f "${_dstfile}"; then | 59 if test -f "${_dstfile}"; then |
57 cp "${_dstfile}" "${_dstfile}.bak" | 60 cp "${_dstfile}" "${_dstfile}.bak" |
58 _echo "${_dstfile} backed up to ${_dstfile}.bak" | 61 _echo "${_dstfile} backed up to ${_dstfile}.bak" |
74 } | 77 } |
75 | 78 |
76 _init() { | 79 _init() { |
77 _script="${HOME}/${3}" | 80 _script="${HOME}/${3}" |
78 _scripttmp="${HOME}/.tmp.${3}" | 81 _scripttmp="${HOME}/.tmp.${3}" |
82 rm -f "${_scripttmp}" | |
79 _data="${2}" | 83 _data="${2}" |
80 if [ -f "${_script}" ]; then | 84 if [ -f "${_script}" ]; then |
81 grep -v "`printf "%s\n" "${_data}" | sed 's/.*#//'`" "${_script}" > "${_scripttmp}" | 85 sed -e "/`_echo "${_data}" | sed -e 's/.*#//'`/d" "${_script}" > "${_scripttmp}" |
82 mv -f "${_scripttmp}" "${_script}" | 86 mv -f "${_scripttmp}" "${_script}" |
83 fi | 87 fi |
84 case "${1}" in | 88 case "${1}" in |
85 install) | 89 install) |
86 _echo "${_data}" >> "${_script}" | 90 _echo "${_data}" >> "${_script}" |
98 EOF | 102 EOF |
99 } | 103 } |
100 | 104 |
101 case "${1}" in | 105 case "${1}" in |
102 install|uninstall) | 106 install|uninstall) |
103 for i in tcsh bash zsh; do | 107 _tcsh "${1}" |
104 _"${i}" "${1}" | 108 _bash "${1}" |
105 done | 109 _zsh "${1}" |
106 _rc "${1}" "tmux" ".tmux.conf" | 110 _rc "${1}" "tmux" ".tmux.conf" |
107 _rc "${1}" "hg" ".hgrc" | 111 _rc "${1}" "hg" ".hgrc" |
108 _rc "${1}" "vimrc" ".vimrc" | 112 _rc "${1}" "vimrc" ".vimrc" |
109 _rc "${1}" "vim-solarized" ".vim/colors/solarized.vim" | 113 _rc "${1}" "vim-solarized" ".vim/colors/solarized.vim" |
110 _rc "${1}" "inputrc" ".inputrc" | 114 _rc "${1}" "inputrc" ".inputrc" |