diff --git a/dots b/dots deleted file mode 100755 index 113749bc..00000000 --- a/dots +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -set -e # -e: exit on error - -#========================================== -# Default argument values and preprocessing -#========================================== -time_str=$(date +'%m-%d-%y_%H:%M:%S') -dotfiles_dir=${dotfiles_dir:-"${HOME}/.local/share/dotfiles"} - -if ! chezmoi="$(command -v chezmoi)"; then - bin_dir="${HOME}/.local/bin" - chezmoi="${bin_dir}/chezmoi" - echo "Installing chezmoi to '${chezmoi}'" >&2 - if command -v curl >/dev/null; then - chezmoi_install_script="$(curl -fsSL https://chezmoi.io/get)" - elif command -v wget >/dev/null; then - chezmoi_install_script="$(wget -qO- https://chezmoi.io/get)" - else - echo "To install chezmoi, you must have curl or wget installed." >&2 - exit 1 - fi - sh -c "${chezmoi_install_script}" -- -b "${bin_dir}" - unset chezmoi_install_script bin_dir -fi - -# POSIX way to get script's dir: https://stackoverflow.com/a/29834779/12156188 -dotfiles_dir="$(cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P)" - -if [ ! -d "${dotfiles_dir}" ]; then - echo "Dotfiles dir '${dotfiles_dir}' does not exist, downloading dotfiles..." - chezmoi init --apply --source="${dotfiles_dir}" -fi - -echo "Running 'chezmoi --source=${dotfiles_dir} $*'" >&2 - -exec "${chezmoi}" --source="${dotfiles_dir}" "$@" diff --git a/install b/install index dff74874..195a528d 100755 --- a/install +++ b/install @@ -4,7 +4,6 @@ ROOT="$(realpath "$(dirname "$0")")" PKGNAME=${PKGNAME:-"dots"} rm -rf "${PKGDIR}/opt/${PKGNAME}" \ - "${PKGDIR}/usr/bin/dots" \ "${PKGDIR}/usr/share/licenses/${PKGNAME}/" \ "${PKGDIR}/usr/share/doc/${PKGNAME}/" @@ -14,15 +13,3 @@ cp -Rf "${ROOT}"/lib "${PKGDIR}/opt/${PKGNAME}" install -Dm644 "${ROOT}"/LICENSE -t "${PKGDIR}/usr/share/licenses/${PKGNAME}/" install -Dm644 "${ROOT}"/README.md -t "${PKGDIR}/usr/share/doc/${PKGNAME}/" -install -Dm755 "${ROOT}"/dots -t "${PKGDIR}/opt/${PKGNAME}/" - -mkdir -p "${PKGDIR}"/usr/bin - -# Create dots binary at ${PKGDIR}/usr/bin/${PKGNAME} to wrap the file at ${PKGDIR}/opt/${PKGNAME}/dots -cat > "${PKGDIR}"/usr/bin/"${PKGNAME}" <&2 + if command -v curl >/dev/null; then + chezmoi_install_script="$(curl -fsSL get.chezmoi.io)" + elif command -v wget >/dev/null; then + chezmoi_install_script="$(wget -qO- get.chezmoi.io)" + else + echo "To install chezmoi, you must have curl or wget installed." >&2 + exit 1 + fi + sh -c "${chezmoi_install_script}" -- -b "${bin_dir}" + unset chezmoi_install_script bin_dir +fi + +# POSIX way to get script's dir: https://stackoverflow.com/a/29834779/12156188 +script_dir="$(cd -P -- "$(dirname -- "$(command -v -- "$0")")" && pwd -P)" + +set -- init --apply --source="${script_dir}" + +echo "Running 'chezmoi $*'" >&2 +# exec: replace current process with chezmoi +exec "$chezmoi" "$@"