alexlemaire/git-assist

View on GitHub
easy-use/Linux/copy-scripts.sh

Summary

Maintainability
Test Coverage
#!/bin/bash

main() {
  read -p "Please provide the path to the repository you would like to copy the scripts to (absolute path): " DEST

  echo "Copying folder..."

  # Copy easy-use scripts folder
  DEST="$(sed "s@~@$HOME@g" <<<$DEST)"
  SRC="$(pwd)"
  FOLDER="$(basename "$SRC")"
  cp -r $SRC $DEST

  # Update .gitignore to not commit easy-use scripts in new repo
  cd $DEST
  FILE=".gitignore"
  if [ -f "$FILE" ]; then
    echo "# Ignore folder for easy-use scripts from git-assist package" >> $FILE
    echo "$FOLDER/" >> $FILE
  fi

  # Update .info to specify that we're not in root anymore
  cd $FOLDER
  echo "copy" > .info
  echo "Done!"
}

export -f main

x-terminal-emulator -e bash -c "main && read -p \"Press Return to exit\""