diff --git a/BOOTSTRAP.sh b/BOOTSTRAP.sh index 05b70d9..6777be8 100644 --- a/BOOTSTRAP.sh +++ b/BOOTSTRAP.sh @@ -1,9 +1,9 @@ #!/usr/bin/env zsh - -set -e # abort when any command errors, prevents this script from self-removing at the end if anything went wrong +set -e # abort when any command errors, prevents self-removing at the end +#─────────────────────────────────────────────────────────────────────────────── # plugin name is the same as the git repo name and can therefore be inferred -repo=$(git remote -v | head -n1 | sed 's/\.git.*//' | sed 's/.*://') +repo=$(git remote -v | head -n1 | sed -e 's/\.git.*//' -e 's/.*:\(.*\) .*/\1/') name=$(echo "$repo" | cut -d/ -f2) name_short=$(echo "$name" | sed -e 's/.nvim$//' -e 's/^nvim-//') @@ -16,13 +16,15 @@ year=$(date +"%Y") #─────────────────────────────────────────────────────────────────────────────── LC_ALL=C # prevent byte sequence error +bootstrap_file=$(basename "$0") # replace them all # $1: placeholder name as {{mustache-template}} # $2: the replacement function replacePlaceholders() { # INFO macOS' sed requires `sed -i ''`, remove the `''` when on Linux or using GNU sed - find . -type f -not -path '*/\.git/*' -not -name ".DS_Store" -exec sed -i '' "s/$1/$2/g" {} \; + find . -type f -not -path '*/\.git/*' -not -name ".DS_Store" -not -name "$bootstrap_file" -exec \ + sed -i '' "s/$1/$2/g" {} \; } replacePlaceholders "%%plugin-name%%" "$name" @@ -32,18 +34,15 @@ replacePlaceholders "%%plugin-name-short%%" "$name_short" #─────────────────────────────────────────────────────────────────────────────── # Files - -# Rename -mv "./lua/plugin-name.lua" "./lua/$name_short.lua" +mkdir ./lua # for panvimdoc -mkdir -p ./doc/ +mkdir ./doc touch "./doc/$name_short.txt" +rm -- "$0" # make this script delete itself + #─────────────────────────────────────────────────────────────────────────────── git add --all && git commit -m "init: bootstrap" - print "\e[1;32mSuccess.\e[0m" - -rm -- "$0" # make this script delete itself