Bash scripts that I use

alias bm="bin/magento"

function phpvm() {
  sudo update-alternatives --config php
  sudo update-alternatives --config php-fpm.sock
  sudo service nginx restart

function xdebug() {
 php_version=$(readlink -f /usr/bin/php | sed 's/\/usr\/bin\///g')

 if [ "$1" != "on" ] && [ "$1" != "off" ]; then
  echo "usage: xdebug [on/off]"
  return 0
 elif [ "$1" = "on" ]; then
  sudo phpenmod xdebug && sudo service "${php_version}-fpm" restart && sudo service nginx restart
 elif [ "$1" = "off" ]; then
  sudo phpdismod xdebug && sudo service "${php_version}-fpm" restart && sudo service nginx restart

Copy and paste it into ~/.bashrc and reopen the terminal to make it work.


Aliasing bin/magento helps you to execute Magento commands faster.

You also do not have to type out the full command names. You can just type the shortest unambiguous name to run a command. So if there are non-clashing commands, then you can run cache:clean like this:
bm c:c

Read more: Symfony Console Shortcut Syntax

phpvm is a handy command that lets you change the currently used PHP version.

xdebug [on/off] is pretty much self-explanatory. It enables or disables Xdebug.