Some frequent drush commands on .bashrc file

Public

consists of drush commands we use frequently which we can place on .bachrc file and execute them calling the corresponding function name.

</> CopyGet raw version
bash
  1. # Thanks to @sbilde for the idea :)
  2. # Append the following into your .bashrc file
  3. # Downloads a module
  4.  
  5. function dl() {
  6. echo enter module name you want to download
  7. read -p "$1"": " module_name
  8. drush dl $module_name
  9. }
  10.  
  11. # Enables a module
  12.  
  13. function en() {
  14. echo enter module name you want to enable
  15. read -p "$1"": " module_name
  16. drush -y en $module_name
  17. }
  18.  
  19. # Disables a module
  20.  
  21. function dis() {
  22. echo enter module name you want to disable
  23. read -p "$1"": " module_name
  24. drush dis -y $module_name
  25. }
  26.  
  27. # Uninstalls a module
  28.  
  29. function un() {
  30. echo enter module name you want to disable
  31. read -p "$1"": " module_name
  32. drush pm-uninstall -y $module_name
  33. }
  34.  
  35. # Downloads drupal/drupal distribution
  36.  
  37. function download_drupal() {
  38. echo enter name for specfic drupal distribution,enter drupal if not sure to download latest drupal version
  39. read -p "$1"": " drupal
  40. drush dl $drupal;
  41. }
  42.  
  43. # Installs drupal with given profile
  44.  
  45. function install_drupal() {
  46. echo enter drupal profile name,enter standard if not sure
  47. read -p "$1"": " profile
  48. echo enter mysql username
  49. read -p "$2"": " mysql_username
  50. echo enter mysql password
  51. read -p "$3"": " mysql_password
  52. echo enter host
  53. read -p "$4"": " host
  54. echo enter database name
  55. read -p "$5"": " db_name
  56. echo enter site account username
  57. read -p "$6"": " account_name
  58. echo enter site account password
  59. read -p "$7"": " account_password
  60. echo enter site account mail address
  61. read -p "$8"": " account_mail
  62. drush site-install $profile --yes --db-url=mysql://$mysql_username:$mysql_password@$host/$db_name --account-name=$account_name --account-pass=$account_password --account-mail=$account_mail
  63. }
  64.  
  65. #fix the admin account blocking due to wrong password enter while logging more than 5 times
  66. function clear_admin_flood() {
  67. drush sqlq "DELETE FROM flood WHERE event = 'failed_login_attempt_user' AND identifier LIKE '1-%'";
  68. }
  69.  
  70. # Fixes the any account blocking due to wrong password enter while logging more than 5 times.
  71.  
  72. function clear_all_flood() {
  73. drush sqlq "DELETE FROM flood";
  74. }
  75.  
  76. # Counts total enabled modules on drupal site
  77.  
  78. function count_enabled_modules() {
  79. drush pml --type=module --status=enabled | wc -l
  80. }
  81.  
  82. # List enabled modules on drupal site
  83.  
  84. function list_enabled_modules() {
  85. drush pml --type=module --status=enabled
  86. }
  87.  
  88. # Tells the status of a module as enabled/or not,returns warning module_name not found if module does not find installed on site.
  89.  
  90. function module_status() {
  91. echo enter module name you want to see status of
  92. read -p "$1"": " module_name
  93. drush pmi $module_name |grep Status
  94. }
  95.  
  96. # Tells all entities on a drupal site
  97.  
  98. function get_entity_list() {
  99. drush ev 'print_r(array_keys(entity_get_info()));'
  100. }

Comments

John Laine's picture

Awesome, Thanks!
A real time saver

Hector's picture

Indeed a time saver!