|
1 | | -<p align="center"> |
2 | | - <img src="https://jessarcher.github.io/zsh-artisan/logo.svg?1" alt="zsh-artisan - Enhanced Laravel integration for zsh" width="400"> |
3 | | -</p> |
4 | | - |
5 | | -This plugin adds an `artisan` shell command with the following features: |
6 | | - |
7 | | -* It will find and execute `artisan` from anywhere within the project file tree |
8 | | - (and you don't need to prefix it with `php` or `./`) |
9 | | -* It provides auto-completion for `artisan` commands (that also work anywhere |
10 | | - within the project). |
11 | | -* You can specify an editor to automatically open new files created by `artisan |
12 | | - make:*` commands |
13 | | - |
14 | | -<p align="center"> |
15 | | - <img src="https://jessarcher.github.io/zsh-artisan/demo.svg?1"> |
16 | | -</p> |
17 | | - |
18 | | -## Requirements |
19 | | - |
20 | | -* [zsh](https://www.zsh.org/) |
21 | | -* [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) |
22 | | -* A [Laravel](https://laravel.com/) project |
23 | | - |
24 | | -## Installation |
25 | | - |
26 | | -### [Antigen](https://github.com/zsh-users/antigen) |
27 | | - |
28 | | -Add the following bundle to your `.zshrc`: |
29 | | - |
30 | | -```zsh |
31 | | -antigen bundle jessarcher/zsh-artisan |
32 | | -``` |
33 | | - |
34 | | -### Oh-my-zsh |
35 | | - |
36 | | -First download the plugin to your oh-my-zsh custom plugin location: |
37 | | - |
38 | | -```zsh |
39 | | -git clone https://github.com/jessarcher/zsh-artisan.git ~/.oh-my-zsh/custom/plugins/artisan |
40 | | -``` |
41 | | - |
42 | | -> Note that the repository name is prefixed with `zsh-`, however the plugin |
43 | | -> directory name should just be "artisan". |
44 | | -
|
45 | | -Then enable the plugin in your `.zshrc` file. For example: |
46 | | - |
47 | | -```zsh |
48 | | -plugins=( |
49 | | - artisan |
50 | | - composer |
51 | | - git |
52 | | -) |
53 | | -``` |
54 | | - |
55 | | -## Configuration |
56 | | - |
57 | | -If you wish to automatically open new files created by `artisan make:*` commands |
58 | | -then you will need to configure the `ARTISAN_OPEN_ON_MAKE_EDITOR` environment |
59 | | -variable. The best place for this is probably your `.zshrc` file. For example: |
60 | | - |
61 | | -```zsh |
62 | | -ARTISAN_OPEN_ON_MAKE_EDITOR=vim |
63 | | -#ARTISAN_OPEN_ON_MAKE_EDITOR=subl # Sublime Text |
64 | | -#ARTISAN_OPEN_ON_MAKE_EDITOR=pstorm # PHPStorm |
65 | | -#ARTISAN_OPEN_ON_MAKE_EDITOR=atom # Atom (May require shell commands to be enabled) |
66 | | -#ARTISAN_OPEN_ON_MAKE_EDITOR=code # VSCode (May require shell commands to be enabled) |
67 | | -``` |
68 | | - |
69 | | -> The author uses [mhinz/neovim-remote](https://github.com/mhinz/neovim-remote), |
70 | | -combined with a wrapper script, to automatically open files in an existing neovim |
71 | | -session within the same tmux session, and automatically switch to the correct |
72 | | -tmux window (tab). |
73 | | - |
74 | | -Note that you will need to re-source your `.zshrc` or restart `zsh` to pick up |
75 | | -the changes. |
76 | | - |
77 | | -## Usage |
78 | | - |
79 | | -Simply use the command `artisan` from anywhere within the directory structure of |
80 | | -a Laravel project and it will search up the tree for the `artisan` command and |
81 | | -execute it. E.g: |
82 | | - |
83 | | -```zshrc |
84 | | -$ pwd |
85 | | -~/MyProject/tests/Feature |
86 | | -
|
87 | | -$ artisan make:model MyAwesomeModel |
88 | | -Model created successfully. |
89 | | -``` |
90 | | - |
91 | | -Tab-completion will work anywhere that `artisan` can be found, and the available |
92 | | -commands are retrieved on-demand. This means that you will see any Artisan |
93 | | -commands that are available to you, including any custom commands that have |
94 | | -been defined. |
95 | | - |
96 | | -If you configured the `ARTISAN_OPEN_ON_MAKE_EDITOR` environment variable, any |
97 | | -files created by `artisan make:*` commands should automatically be opened, |
98 | | -including when multiple files are created (E.g. by `artisan make:model -m -c -r`) |
99 | | - |
100 | | -The plugin does not create any aliases for you, but the author would like to |
101 | | -offer some suggestions: |
102 | | - |
103 | | -```zsh |
104 | | -alias a="artisan" |
105 | | -alias tinker="artisan tinker" |
106 | | -alias serve="artisan serve" |
107 | | -``` |
108 | | - |
109 | | -Many more can be found at https://laravel-news.com/bash-aliases |
110 | | - |
111 | | -## Homestead Setup |
112 | | - |
113 | | -The Zsh Artisan plugin can be installed automatically with any new or provisioned Laravel Homestead instance. |
114 | | -In the root of your Homestead project, add the following to your `after.sh` file. |
115 | | -```bash |
116 | | -ARTISAN=/home/vagrant/.oh-my-zsh/custom/plugins/artisan |
117 | | -if [ -d "$ARTISAN" ]; then |
118 | | - echo "$ARTISAN exist" |
119 | | -else |
120 | | - git clone https://github.com/jessarcher/zsh-artisan.git $ARTISAN |
121 | | - sed -i 's/plugins=(git)/plugins=(git composer artisan)/g' /home/vagrant/.zshrc |
122 | | - source /home/vagrant/.zshrc |
123 | | -fi |
124 | | -``` |
125 | | -*Note:* If you are re-provisioning your Homstead box, and already have other Zsh plugins defined in your Zsh config files, you wil need to adjust the `sed` command to includes those in the list. |
126 | | - |
127 | | -## License |
128 | | - |
129 | | -This project is open-sourced software licensed under the MIT License - see the |
130 | | -[LICENSE](LICENSE) file for details |
131 | | - |
132 | | -## Acknowledgements |
133 | | - |
134 | | -* [antonioribeiro/artisan-anywhere](https://github.com/antonioribeiro/artisan-anywhere) |
135 | | - for some of the initial artisan location logic |
136 | | -* The `laravel5` plugin that comes with oh-my-zsh for the initial completion |
137 | | - logic |
138 | | -* [ahuggins/open-on-make](https://github.com/ahuggins/open-on-make) for the |
139 | | - "open on make" functionality idea. Unfortunately, adding a dev dependency like |
140 | | - this isn't an option on some of the projects I work on. |
| 1 | +A fork of [jessarcher/zsh-artisan](https://github.com/jessarcher/zsh-artisan), but for Statamic's `please` command. |
0 commit comments