diff options
-rwxr-xr-x | install.sh | 64 | ||||
-rwxr-xr-x | nvim/install.sh | 8 | ||||
-rwxr-xr-x | sheldon/install.sh | 8 |
3 files changed, 9 insertions, 71 deletions
@@ -1,64 +1,14 @@ #!/bin/sh +# shellcheck disable=SC2035 -SCRIPT="$(basename "$0")" -SCRIPT_DIR="$(dirname -- "$(readlink -f -- "$0")")" -INSTALL_DIR="$(dirname "$SCRIPT_DIR")" +CDPATH='' cd -- "$(dirname -- "$0")" || exit -long='clean-only,help' -short='ch' +printf "%s: Removing bad links\n" "$0" +chkstow -t .. -b | cut -c13- | xargs -r rm -v -if ! opts="$(getopt -o $short -l $long -n "$SCRIPT" -- "$@")"; then - exit 1 -fi +printf "%s: Stowing packages\n" "$0" +stow "$@" */ -eval set -- "$opts" - -help() { - cat <<-EOF - $SCRIPT - Toby Vincent <tobyv@tobyvin.dev> - - $SCRIPT - Installer script that is a simple wrapper around GNU stow that removes broken symlinks - found in $INSTALL_DIR, stows all packages, and runs all ./*/install.sh scripts. - - USAGE: - $SCRIPT [OPTION ...] - - OPTIONS: - -h, --help Show this help. - EOF -} - -clean_only=false -while true; do - case "$1" in - -h | --help) - help - exit 0 - ;; - -c | --clean-only) - clean_only=true - shift - ;; - --) - shift - break - ;; - *) - exit 1 - ;; - esac -done - -find . -type l -exec sh -c 'for x; do [ -e "$x" ] || rm -v "$x"; done' _ {} + - -if $clean_only; then - exit 0 -fi - -stow "$@" -- */ - -for f in "$SCRIPT_DIR"/*/install.sh; do +for f in */install.sh; do $f done diff --git a/nvim/install.sh b/nvim/install.sh index f4efb7c..524c91b 100755 --- a/nvim/install.sh +++ b/nvim/install.sh @@ -1,11 +1,5 @@ #!/bin/sh -SCRIPT="$0" - -say() { - printf "%s: %s\n" "$SCRIPT" "$@" -} - -say "Installing plugins..." +printf "%s: Restoring plugins\n" "$0" nvim --headless -c 'Lazy! restore' -c qa nvim --headless -c 'Lazy! clean' -c qa diff --git a/sheldon/install.sh b/sheldon/install.sh index 9161bac..810eae2 100755 --- a/sheldon/install.sh +++ b/sheldon/install.sh @@ -1,10 +1,4 @@ #!/bin/sh -SCRIPT="$0" - -say() { - printf "%s: %s\n" "$SCRIPT" "$@" -} - -say "Installing plugins" +printf "%s: Installing plugins\n" "$0" sheldon lock |