Last active
September 25, 2023 18:57
-
-
Save xjm/2244c58c031a46fe9d48001c6a3dff97 to your computer and use it in GitHub Desktop.
Parts of xjm's .bash_profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make git branch tab completion possible | |
if [ -f ~/.git-completion.bash ]; then | |
. ~/.git-completion.bash | |
fi | |
# Resets a Drupal installation (destroying all data) without reinstalling. | |
# Run this command directly to clean up the old installation before | |
# reinstalling manually. | |
function drupal-reset() { | |
# Remove existing database. | |
drush sql-drop -y; | |
# Remove existing installation. | |
sudo rm -rf sites/default; | |
# Restore the sites/default/default.settings.php file. | |
sudo git checkout -- sites/default; | |
# Temporarily make the sites/default writable by anyone. | |
sudo chmod -R 777 sites/default; | |
# Ensure the owner is the current user, not the root user. | |
sudo chown -R `whoami` sites/default; | |
# Now that it is writeable, restore the directory from the branch. | |
sudo git checkout -- sites/default; | |
# Ensure that we still own the folder. | |
sudo chown -R `whoami` sites/default; | |
# Remove the old vendor directory for a fresh composer install. | |
sudo rm -rf vendor; | |
composer install | |
# Use PHPUnit 6. | |
#composer run-script drupal-phpunit-upgrade | |
} | |
# Performs Drupal quickstart installation. Run this after drupal-reset(). | |
function quickstart() { | |
php core/scripts/drupal quick-start standard | |
} | |
# Sets up settings.php and settings.local.php to be writeable after install. | |
function drupal-write-settings() { | |
sudo chown -R `whoami` sites/default; | |
sudo chmod -R 755 sites/default; | |
cp sites/example.settings.local.php sites/default/settings.local.php | |
} | |
# Reinstalls Drupal 8 with a particular install profile, destroying all data. | |
# Usage: drupal-install 'minimal' | |
# By default, the 'standard' profile is used. | |
function drupal-install() { | |
drupal-reset | |
sudo cp sites/example.settings.local.php sites/default/settings.local.php | |
echo " if (file_exists(\$app_root . '/' . \$site_path . '/settings.local.php')) { include \$app_root . '/' . \$site_path . '/settings.local.php'; }" >> sites/default/default.settings.php | |
# Accept an install profile as an argument. | |
if [ $1 ] ; then | |
drush si $1 --db-url=mysql://d8:d8@localhost/d8 --account-name=admin --account-pass=admin -y | |
else | |
drush si --db-url=mysql://d8:d8@localhost/d8 --account-name=admin --account-pass=admin -y | |
fi | |
} | |
function ca() { | |
curl $1 | git apply --index - | |
reset | |
} | |
function reset() { | |
rm -rf vendor | |
composer install | |
(cd core; rm -rf node_modules; yarn install) | |
} | |
function commit-check() { | |
reset | |
core/scripts/dev/commit-code-check.sh --cached | |
} | |
alias githash='git log -n 1 --pretty=format:"%H" | pbcopy' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment