Laravel Bash Aliases

Developer Tools

August 24th, 2017

Laravel Bash Aliases

Bash aliases are shortcuts added to a file that allows you to reference another command through more memorable words, abbreviations, or characters. For example, if you use Git you may run git status many times throughout the day, so to save yourself time and keystrokes you could alias gs to git status and it’ll automatically expand and call the proper command.

Over the years I’ve seen a lot of unusual aliases and many are unique to the person. Shortcuts that make sense to me, might be confusing and weird to you. That’s what makes these so fun.

To gain some insights into what others are doing I asked the community to share theirs with me and quite a few responded. It surprised me how many are similar in that almost everyone made shortcuts for the Artisan command. Yet everyone has a different shortcut pattern, for example, “a”, “pa”, or “art” for the php artisan command. Another unique one that a few shared is a command called “nah”:

1nah='git reset --hard;git clean -df'

That one is really nice and to demonstrate how it works, pretend that you started working on a new feature, maybe added a few new files, and then after lunch, you decide everything you’ve done is wrong. By running the nah command it’ll reset your code back to what is committed, and delete any files that are not known to git. Very convenient and useful!

How To Create Your Own Base Aliases

For those new to creating bash aliases, the process is pretty simple. First, open up the ~/.bashrc file in a text editor that is found in your home directory. Uncomment or add the following lines:

1if [ -f ~/.bash_aliases ]; then
2. ~/.bash_aliases

This tells it to load a .bash_aliases file, if it exists, so you can put all your aliases in it and make them easier to share and keep up with. Finally, create the ~/.bash_aliases file and add the following as your first alias:

1alias art="php artisan"

Save the file and type the following in the terminal:

1source ~/.bashrc

From here on you should be able to type art and it’ll auto expand into php artisan. Just remember that every time you modify the bash_aliases file you’ll need to either run that source command or restart Terminal so the changes are picked up.

Laravel Bash Aliases from the Community

Below is a list of all the Laravel community contributions and what they are using.


1# Laravel
3artisan() {
4 if [ -f bin/artisan ]; then
5 php bin/artisan "$@"
6 else
7 php artisan "$@"
8 fi
11alias serve='artisan serve'
12alias tinker='artisan tinker'
15# Misc PHP
17t() {
18 if [ -f vendor/bin/phpunit ]; then
19 vendor/bin/phpunit "$@"
20 else
21 phpunit "$@"
22 fi


1nah='git reset --hard;git clean -df'
2vm='ssh vagrant@ -p 2222'


1pa='php artisan'

Mohamed Said

1alias dracarys="git reset --hard && git clean -df"
2alias copyssh="pbcopy < $HOME/.ssh/"
3alias reloadcli="source $HOME/.zshrc"
4alias zshrc="/Applications/Sublime\ ~/.zshrc "
5alias shrug="echo '¯\_(ツ)_/¯' | pbcopy";
6alias fight="echo '(ง'̀-'́)ง' | pbcopy";
8*** This one opens a PR from the current branch
9function openpr() {
10 br=`git branch | grep "*"`
11 repo=$1
12 parentBranch=$2
14 open -a /Applications/Google\${repo/* /}/compare/${parentBranch/* /}...themsaid:${br/* /}\?expand\=1

Jeffrey Way

1alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
2alias wip="git add . && git commit -m 'wip'"
3alias nah="git reset --hard && git clean -df"
4alias p="phpunit"
5alias pf="phpunit --filter "
6alias art="php artisan"
7alias migrate="php artisan migrate"

Bill Mitchell

1alias a="php artisan"
2alias pu="vendor/bin/phpunit"
3alias puf="vendor/bin/phpunit --filter "
4alias pug="vendor/bin/phpunit --group "
5alias cdo="composer dump-autoload -o"
6alias serve="php artisan serve"

Jesús Amieiro

1alias pa='php artisan'
2alias par:l='php artisan route:list'
3alias pam='php artisan migrate'
4alias pam:r='php artisan migrate:refresh'
5alias pam:rs='php artisan migrate:refresh --seed'
6alias cu='composer update'
7alias ci='composer install'
8alias cda='composer dump-autoload -o'
9alias vu='cd ~/Homestead && vagrant up'
10alias vs='vagrant suspend'
11alias vssh='vagrant ssh'


1alias artisan = "php artisan"
2alias db-reset="php artisan migrate:reset && php artisan migrate --seed"


1alias a="php artisan"


1alias _='sudo'
2alias art='php artisan'
3alias tinker='php artisan tinker'
4alias ll="ls -lh"
5alias la='ls -lAh'
6alias c='composer'
7alias iphp='psysh' # repl
8alias g='git'
9alias gs='git status'
10alias d='docker'
11alias dc='docker-compose'
12alias dm='docker-machine'
13alias k='kubectl'
14alias publicip='dig +short'
15alias chrome="/Applications/Google\\ Chrome"
17# Show file and folder permissions as octal
18# Usage: `octal file.txt` or `octal my/path`
19alias octal="stat -f '%A %a %N'"
21# Mac conveniences for Linux
22alias pbcopy='xclip -selection clipboard'
23alias pbpaste='xclip -selection clipboard -o'
24if type "xdg-open" &> /dev/null; then
25 alias open="xdg-open"

TJ Miller

1nah: aliased to git reset --hard && git clean -fd
2aa: aliased to php artisan


1# Hub (extend git commands)
2alias git=hub
4# Directories
5alias ll='ls -FGlAhp'
6alias ..="cd ../"
7alias ...="cd ../../"
8alias ....="cd ../../../"
9alias .....="cd ../../../../"
11alias df="df -h"
12alias diskusage="df"
13alias fu="du -ch"
14alias folderusage="fu"
15alias tfu="du -sh"
16alias totalfolderusage="tfu"
18alias finder='open -a 'Finder' .'
20# Vagrant
21alias vagrantgo="vagrant up && vagrant ssh"
22alias vgo="vagrantgo"
23alias vhalt="vagrant halt"
24alias vreload="vagrant reload && vgo"
26# PHP
27alias c='composer'
28alias cr='composer require'
29alias cda='composer dumpautoload'
30alias co='composer outdated --direct'
31alias update-global-composer='cd ~/.composer && composer update'
32alias composer-update-global='update-global-composer'
34alias a='php artisan'
35alias pa='php artisan'
36alias phpa='php artisan'
37alias art='php artisan'
38alias arti='php artisan'
40alias test='vendor/bin/phpunit'
42alias y='yarn'
43alias yr='yarn run'
45# Homestead
46alias edithomestead='open -a "Visual Studio Code" ~/Homestead/Homestead.yaml'
47alias homesteadedit='edithomestead'
48alias dev-homestead='cd ~/Homestead && vgo'
49alias homestead-update='cd ~/Homestead && vagrant box update && git pull origin master'
50alias update-homestead='homestead-update'
52# Various
53alias editaliases='open -a "Visual Studio Code" ~/.bash_aliases'
54alias showpublickey='cat ~/.ssh/'
55alias ip="curl"
56alias localip="ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v ''"
57alias copy='rsync -avv --stats --human-readable --itemize-changes --progress --partial'
59# Functions
60mkcdir ()
62 mkdir -p -- "$1" &&
63 cd -P -- "$1"
66function homestead() {
67 ( cd ~/Homestead && vagrant $* )

Alexander Melihov

1alias ars="php artisan serve"
2alias art="php artisan tinker"


1alias l="php artisan"


1alias unit='php vendor/phpunit/phpunit/phpunit'
3alias unitreport='php -d xdebug.profiler_enable=On vendor/phpunit/phpunit/phpunit --coverage-html=./public/report'
5alias laravel-installer='composer create-project --prefer-dist laravel/laravel'


1alias artisan="php artisan"
2alias cclear='php artisan cache:clear'
3# now with 5.5
4alias fresh="artisan migrate:fresh --seed"


1alias pf="phpunit --filter"
2alias artisan="php artisan"
3alias tinker="php artisan tinker"


1alias mfs="php artisan migrate:fresh --seed'

Filed in:

Eric L. Barnes

Eric is the creator of Laravel News and has been covering Laravel since 2012.