This plugin adds an artisan
shell command with the following features:
- It will find and execute
artisan
from anywhere within the project file tree (and you don't need to prefix it withphp
or./
) - It provides auto-completion for
artisan
commands (that also work anywhere within the project). - You can specify an editor to automatically open new files created by
artisan make:*
commands
Add the following bundle to your .zshrc
:
antigen bundle jessarcher/zsh-artisan
First download the plugin to your oh-my-zsh custom plugin location:
git clone https://github.com/jessarcher/zsh-artisan.git ~/.oh-my-zsh/custom/plugins/artisan
Note that the repository name is prefixed with
zsh-
, however the plugin directory name should just be "artisan".
Then enable the plugin in your .zshrc
file. For example:
plugins=(
artisan
composer
git
)
If you wish to automatically open new files created by artisan make:*
commands
then you will need to configure the ARTISAN_OPEN_ON_MAKE_EDITOR
environment
variable. The best place for this is probably your .zshrc
file. For example:
ARTISAN_OPEN_ON_MAKE_EDITOR=vim
#ARTISAN_OPEN_ON_MAKE_EDITOR=subl # Sublime Text
#ARTISAN_OPEN_ON_MAKE_EDITOR=pstorm # PHPStorm
#ARTISAN_OPEN_ON_MAKE_EDITOR=atom # Atom (May require shell commands to be enabled)
#ARTISAN_OPEN_ON_MAKE_EDITOR=code # VSCode (May require shell commands to be enabled)
The author uses mhinz/neovim-remote, combined with a wrapper script, to automatically open files in an existing neovim session within the same tmux session, and automatically switch to the correct tmux window (tab).
Note that you will need to re-source your .zshrc
or restart zsh
to pick up
the changes.
Simply use the command artisan
from anywhere within the directory structure of
a Laravel project and it will search up the tree for the artisan
command and
execute it. E.g:
$ pwd
~/MyProject/tests/Feature
$ artisan make:model MyAwesomeModel
Model created successfully.
Tab-completion will work anywhere that artisan
can be found, and the available
commands are retrieved on-demand. This means that you will see any Artisan
commands that are available to you, including any custom commands that have
been defined.
If you configured the ARTISAN_OPEN_ON_MAKE_EDITOR
environment variable, any
files created by artisan make:*
commands should automatically be opened,
including when multiple files are created (E.g. by artisan make:model -m -c -r
)
The plugin does not create any aliases for you, but the author would like to offer some suggestions:
alias a="artisan"
alias tinker="artisan tinker"
alias serve="artisan serve"
Many more can be found at https://laravel-news.com/bash-aliases
This project is open-sourced software licensed under the MIT License - see the LICENSE file for details
- antonioribeiro/artisan-anywhere for some of the initial artisan location logic
- The
laravel5
plugin that comes with oh-my-zsh for the initial completion logic - ahuggins/open-on-make for the "open on make" functionality idea. Unfortunately, adding a dev dependency like this isn't an option on some of the projects I work on.