Last active
March 10, 2020 02:23
-
-
Save gh640/e4c1295bca1d3ef2c8372e7834ca54df to your computer and use it in GitHub Desktop.
Deprecated bash functions/aliases on macOS
This file contains hidden or 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
| # Shortcut to download and install a Drupal project on Drupal 7 | |
| function den { | |
| local module_name | |
| if [[ "${1}" == *"https://www.drupal.org/project"* ]]; then | |
| module_name=$(echo "${1}" | grep -Eo "[^\/]+$") | |
| echo "$module_name is being installed..." | |
| else | |
| module_name="${1}" | |
| fi | |
| drush en "$module_name" | |
| } |
This file contains hidden or 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
| alias dcc='drush cc all' | |
| alias den='drush en' | |
| alias ddis='drush dis' | |
| alias drupal_maintenance_on='drush vset maintenance_mode 1' | |
| alias drupal_maintenance_off='drush vset maintenance_mode 0' | |
| alias drupal_log_tail='tail -f /tmp/drupal_debug.txt' | |
| alias drupal_devel_mails="open /tmp/devel-mails" |
This file contains hidden or 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
| # Check the Drupal database size on Drupal 7 | |
| function drupal_database_get_size { | |
| local drupal_db_name | |
| drupal_db_name="$(drush sql-conf | grep "database" | grep -Eo "\S+$")" | |
| if [[ -z "$drupal_db_name" ]]; then | |
| echo "usage: run this command under a drupal instance directory." | |
| return | |
| fi | |
| $(drush sql-connect) -e "SELECT table_schema AS \"Database\", sum(round(((data_length + index_length) / 1024 / 1024), 2)) AS \"Size in MB\" FROM information_schema.TABLES WHERE table_schema = \"$drupal_db_name\"" | |
| } | |
This file contains hidden or 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
| # Generate a random password with Drupal 7 | |
| function drupal_password_generate { | |
| local length | |
| if [ -z "${1}" ]; then | |
| length=16 | |
| else | |
| length="${1}" | |
| fi | |
| drush eval "print user_password($length) . PHP_EOL" | |
| } | |
This file contains hidden or 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
| # Set drupal japanese setting on Drupal 7 | |
| function drupal_set_lang_ja { | |
| drush en locale && \ | |
| drush dl drush_language && \ | |
| drush cc drush && \ | |
| drush language-add ja && \ | |
| drush language-default ja && \ | |
| drush en l10n_update && \ | |
| drush cc drush && \ | |
| drush l10n-update | |
| } |
This file contains hidden or 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
| # Install Drupal 7 with MySQL database installed with Homebrew | |
| function drupal_site_install { | |
| if [ -z "${1}" ]; then | |
| echo "usage: ${FUNCNAME[1]} db(=site)name" | |
| return | |
| fi | |
| if [ -e "${1}" ]; then | |
| echo "${1} file/dir exists." | |
| return | |
| fi | |
| database_num=$(mysql -e"show databases" | grep -c "^${1}$") | |
| if [ "$database_num" == 1 ]; then | |
| echo "${1} database exists." | |
| return | |
| fi | |
| drush si --db-url="mysql://$(whoami)@127.0.0.1:3306/${1}" \ | |
| --account-name=admin \ | |
| --account-pass=admin \ | |
| --site-name="${1}" | |
| } |
This file contains hidden or 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
| # Rsync theme directory to @dev machine on Drupal 7 | |
| function drupal_theme_dev_auto_upload { | |
| watchmedo shell-command \ | |
| --patterns="*.php;*.css;*.png;*.jpg" \ | |
| --recursive \ | |
| --command='drush rsync @self:sites/all/themes @dev:sites/all/themes' | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment