I always create aliases and helper functions for everything in bash. Here’s a list of some of my favorites.

Source code editor alias

I installed the alias of my source code editor. You’ll sometimes see sbl . It’s the alias for Sublime text. Feel free to replace this alias by the alias of your editor like atom for Atom or code for Visual Studio Code for example.

Terminal

Useful alias for bash commands:

alias ls='ls -aGFh'

alias ll='ls -l'

alias rm='rm -i'

alias ne='emacs'

Folders

I always create aliases to access quickly and easily to my dev folders like:

alias dev='cd ~/dev'

System

I create aliases for accessing to system features like hosts, bash profile and git configuration.

alias profile='subl ~/.bash_profile'

alias resource='source ~/.bash_profile && echo "✅ Done"'

alias hosts='sudo sbl /etc/hosts'

alias gitconfig='subl ~/.gitconfig'

Because I’m on Mac, I created aliases to access easily to my iCloud Drive:

alias ic='cd ~/Library/Mobile\ Documents/com~apple~CloudDocs'

alias icd='cd ~/Library/Mobile\ Documents/com~apple~CloudDocs/Documents'

Git

Aliases for git commands:

alias g='git'

alias gi='git init'

alias gs='git status'

alias ga='git add -A .'

alias grh="git reset --hard"

alias gc='git commit -am'

alias push='git push'

alias gl='git log --oneline --decorate --color'

alias pull='git pull'

alias gd='git diff'

alias gb='git branch'

alias gf='git fetch'

Quick update

Ok, shame on me 🙈, but sometimes you want to quickly update your repo using git:

# Quick add, commit and push on origin branch with Git

function gq {

git add .

git commit -m "Quick update"

git push origin master

}

PHP

Aliases to launch a PHP server:

alias serve='php -S 0.0.0.0:8080 index.php'

alias servep='php -S 0.0.0.0:8080 -t public public/index.php'

Composer

Aliases for Composer, the dependency manager for PHP:

alias cc='composer clear-cache'

alias cu='composer update'

alias ci='composer install'

alias cdo='composer dump-autoload -o'

Laravel

Some useful aliases for Laravel framework:

alias art='php artisan'

alias log='tail -n0 -f storage/logs/laravel.log'

Valet

If you use Laravel Valet and you want to fast check your local websites:

alias vls='valet links'

Jekyll

Jekyll is my favorite tool for creating static website. That’s why I created aliases to build and serve my Jekyll websites:

alias jn='jekyll new'

alias jb='bundle exec jekyll build'

alias js='bundle exec jekyll serve'

alias jsd='bundle exec jekyll serve --drafts'

alias jbw='bundle exec jekyll build --watch'

Server

Bash functions for you servers:

Update a server

If you want to update a server:

function update-server {

echo -e '\033[1m\033[32mUpdating server...\033[0m'

ssh -t user@123.45.6.789 -p 1234 'sudo apt-get update; sudo apt-get upgrade; sudo apt autoremove';

echo -e '\033[1m\033[32m✅ Done

\033[0m'

}

Replace user@123.45.6.789 -p 1234 by your server user, ip address and port.

Local MySql backup on iCloud Drive

Sometimes, I want to backup my local MySQL databases on iCloud Drive. I created a backup folder on iCoud Drive to put the saved databases inside. Then I launch this command:

function backup {

folder="/Users/clement/Library/Mobile Documents/com~apple~CloudDocs/backups"

filename="$(date +%Y%m%d)-backup"

mysqldump -u root -p --all-databases --single-transaction > "$folder/$filename.sql"

echo -e '\033[1m\033[32m✅ MySql backup done

\033[0m'

}

Replace clement in the folder variable by your Mac username.

Quickly deploy a website using Git

You want to quickly deploy your website using git on your server? Try this:

function deploy {

echo -e '\033[1m\033[36m

Deploy your website

\033[0m'

ssh -t user@123.45.6.789 -p 1234 'cd /var/www/website; git pull origin master;'

echo -e '\033[1m\033[32m✅ Done

\033[0m'

}