dotfiles

regexghost dotfiles and scripts
git clone https://git.regexghost.com/dotfiles.git
Log | Files | Refs | README

setup.sh (1052B)


      1 #!/bin/sh
      2 
      3 file="lists/$2"
      4 
      5 exec 3<&0
      6 if [ "$1" = "save" ]; then
      7 	while read -r filepath; do
      8 		repo_path=$(echo "$filepath" | sed "s|~|$2|g")
      9 		real_path=$(echo "$filepath" | sed "s|~|$HOME|g")
     10 		basename=$(basename "$filepath")
     11 		repo_dirname=$(dirname "$repo_path")
     12 		mkdir -p "$repo_dirname"
     13 		echo $filepath
     14 		if grep -q "Start Substitute" "$real_path"; then
     15 			sub save "$basename" "$repo_dirname" "$real_path" <&3
     16 			sub clean "$basename" "$repo_dirname" "$real_path" "$repo_path"
     17 		else
     18 			cp "$real_path" "$repo_path"
     19 		fi
     20 	done < $file
     21 elif [ "$1" = "make" ]; then
     22 	while read -r filepath; do
     23 		repo_path=$(echo "$filepath" | sed "s|~|$2|g")
     24 		real_path=$(echo "$filepath" | sed "s|~|$HOME|g")
     25 		basename=$(basename "$filepath")
     26 		real_dirname=$(dirname "$real_path")
     27 		repo_dirname=$(dirname "$repo_path")
     28 		echo $filepath
     29 		mkdir -p "$real_dirname"
     30 		if grep -q "Start Substitute" "$repo_path"; then
     31 			sub make "$basename" "$repo_dirname" "$repo_path" "$real_path" <&3
     32 		else
     33 			cp "$repo_path" "$real_path"
     34 		fi
     35 	done < $file
     36 fi
     37 exec 3<&-