2016-03-29 2 views
1

Я хочу быть создать artisan команду в Vim, так что я могу сделать что-то вроде:Выполнение пользовательской команды с Vim

:artisan make:migration create_blah_table --create=blah 

И запустить его в следующем:

ssh -t vagrant "cd /var/www && php artisan make:migration create_blah_table --create=blah" 

Это возможное?

Update

make:migration create_blah_table --create=blah бит может быть что угодно.

ответ

3

См :help user-commands:

It is possible to define your own Ex commands. A user-defined command can act 
just like a built-in command (it can have a range or arguments, arguments can 
be completed as filenames or buffer names, etc), except that when the command 
is executed, it is transformed into a normal Ex command and then executed. 

For starters: See section |40.2| in the user manual. 

      *E183* *E841* *user-cmd-ambiguous* 
All user defined commands must start with an uppercase letter, to avoid 
confusion with builtin commands. 

Вы хотите :command

:com[mand][!] [{attr}...] {cmd} {rep} 
         Define a user command. The name of the command is 
         {cmd} and its replacement text is {rep}. The command's 
         attributes (see below) are {attr}. If the command 
         already exists, an error is reported, unless a ! is 
         specified, in which case the command is redefined. 

Вы можете сделать это в вашем ~/.vimrc:

command -nargs=* Artisan !ssh -t vagrant "cd /var/www && php artisan <args>" 

И затем использовать команду :Artisan make:migration create_blah_table --create=blah в экс-режиме.

+0

«make: migration create_blah_table --create = blah' не хочет быть жестко закодированным в команде. Я хочу иметь возможность запускать ': Artisan whatever' и запускать' ssh -t vagrant 'cd/var/www && php artisan что угодно "' –

+0

Маленький адронный коллайдер: кричит, пропустил это. исправлено. – rampion

+0

Я получаю ошибку 'E488: Trailing characters ', когда я пытаюсь запустить, например. 'Artisan cache: clear' –

Смежные вопросы