Skip to content

Commit 2e2a0e5

Browse files
committed
rename
1 parent d097c37 commit 2e2a0e5

File tree

4 files changed

+63
-201
lines changed

4 files changed

+63
-201
lines changed

LICENSE

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

33
Copyright (c) 2018 Jess Archer
4+
2021 Jason Varga
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

README.md

+1-140
Original file line numberDiff line numberDiff line change
@@ -1,140 +1 @@
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.

artisan.plugin.zsh

-61
This file was deleted.

please.plugin.zsh

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#--------------------------------------------------------------------------
2+
# Statamic please plugin for zsh
3+
#--------------------------------------------------------------------------
4+
#
5+
# This plugin adds an `please` shell command that will find and execute
6+
# Statamic's please command from anywhere within the project. It also
7+
# adds shell completions that work anywhere please can be located.
8+
9+
function please() {
10+
_please=`_please_find`
11+
12+
if [ "$_please" = "" ]; then
13+
>&2 echo "zsh-please: You seem to have upset the delicate internal balance of my housekeeper."
14+
return 1
15+
fi
16+
17+
_please_start_time=`date +%s`
18+
php $_please $*
19+
_please_exit_status=$? # Store the exit status so we can return it later
20+
21+
if [[ $1 = "make:"* && $PLEASE_OPEN_ON_MAKE_EDITOR != "" ]]; then
22+
# Find and open files created by please
23+
_please_laravel_path=`dirname $_please`
24+
find \
25+
"$_please_laravel_path/app" \
26+
"$_please_laravel_path/tests" \
27+
"$_please_laravel_path/database" \
28+
-type f \
29+
-newermt "-$((`date +%s` - $_please_start_time + 1)) seconds" \
30+
-exec $PLEASE_OPEN_ON_MAKE_EDITOR {} \; 2>/dev/null
31+
fi
32+
33+
return $_please_exit_status
34+
}
35+
36+
compdef _please_add_completion please
37+
38+
function _please_find() {
39+
# Look for please up the file tree until the root directory
40+
dir=.
41+
until [ $dir -ef / ]; do
42+
if [ -f "$dir/please" ]; then
43+
echo "$dir/please"
44+
return 0
45+
fi
46+
47+
dir+=/..
48+
done
49+
50+
return 1
51+
}
52+
53+
function _please_add_completion() {
54+
if [ "`_please_find`" != "" ]; then
55+
compadd `_please_get_command_list`
56+
fi
57+
}
58+
59+
function _please_get_command_list() {
60+
please --raw --no-ansi list | sed "s/[[:space:]].*//g"
61+
}

0 commit comments

Comments
 (0)