GithubHelp home page GithubHelp logo

doc0x1 / artisan Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jessarcher/zsh-artisan

0.0 0.0 0.0 46 KB

Laravel artisan plugin for zsh to help you to run artisan from anywhere in the project tree, with auto-completion, and it can automatically open files created by artisan!

License: MIT License

Shell 100.00%

artisan's Introduction

This is simply a fork of the https://github.com/jessarcher/zsh-artisan.git repository

zsh-artisan - Enhanced Laravel integration for zsh

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 with php 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

Requirements

Installation

Add the following bundle to your .zshrc:

antigen bundle jessarcher/zsh-artisan

Oh-my-zsh

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
)

Configuration

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.

Usage

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

Homestead Setup

The Zsh Artisan plugin can be installed automatically with any new or provisioned Laravel Homestead instance. In the root of your Homestead project, add the following to your after.sh file.

ARTISAN=/home/vagrant/.oh-my-zsh/custom/plugins/artisan
if [ -d "$ARTISAN" ]; then
  echo "$ARTISAN exist"
else
  git clone https://github.com/jessarcher/zsh-artisan.git $ARTISAN
  sed -i 's/plugins=(git)/plugins=(git composer artisan)/g' /home/vagrant/.zshrc
  source /home/vagrant/.zshrc
fi

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.

License

This project is open-sourced software licensed under the MIT License - see the LICENSE file for details

Acknowledgements

  • 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.

artisan's People

Contributors

doc0x1 avatar georanma avatar jessarcher avatar noreason avatar sifex avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.