From baa6bd68d2505db9e8261d046791a4b0772575d8 Mon Sep 17 00:00:00 2001 From: Mark Riedesel Date: Fri, 12 Apr 2024 15:46:49 -0400 Subject: [PATCH] default to installing when piped --- bin/dotfiles | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/dotfiles b/bin/dotfiles index 322f0aa..8b6d4cf 100755 --- a/bin/dotfiles +++ b/bin/dotfiles @@ -1,10 +1,10 @@ -#!/bin/sh -e +#!/bin/zsh -e DOTFILES_HOME="${DOTFILES_HOME:-$HOME}" DOTFILES_ROOT="${DOTFILES_ROOT:-$DOTFILES_HOME/.dotfiles}" DOTFILES_REMOTE="${DOTFILES_REMOTE:-git@github.com:Klowner/dotfiles}" DOTFILES_WORK_TREE="${DOTFILES_WORK_TREE:-$HOME}" DOTFILES_ALIAS="/usr/bin/git --git-dir=${DOTFILES_ROOT} --work-tree=${DOTFILES_WORK_TREE}" -DEPENDENCIES=(git) +DEPENDENCIES=(git zsh) function has() { return $(which $1 &> /dev/null) @@ -25,7 +25,7 @@ function info() { function smart_clone() { if [ -d $DOTFILES_ROOT ]; then EXISTING_REMOTE=$(git --git-dir=${DOTFILES_ROOT} remote get-url origin) - if [ $EXISTING_REMOTE == $DOTFILES_REMOTE ]; then + if [ "$EXISTING_REMOTE" = "$DOTFILES_REMOTE" ]; then dotfiles fetch else die "$DOTFILES_ROOT already exists, aborting." @@ -45,7 +45,6 @@ function dotfiles() { eval $DOTFILES_ALIAS $* } - function backup_existing() { dotfiles checkout DST="${DOTFILES_ROOT}-backup" @@ -62,6 +61,13 @@ function install() { dotfiles config --local status.showUntrackedFiles no } +# If this script is being piped from curl +if ! tty >/dev/null; then + install + exit 0 +fi + +# Command line mode case "${1:-help}" in info) info;; install) install;;