我想在Vim中创建一个artisan
命令,所以我可以这样做:
:artisan make:migration create_blah_table --create=blah
让它运行以下内容:
ssh -t vagrant "cd /var/www && php artisan make:migration create_blah_table --create=blah"
这可能吗?
更新
make:migration create_blah_table --create=blah
位可能是任何东西。
答案 0 :(得分: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>"
然后在ex-mode中使用:Artisan make:migration create_blah_table --create=blah
命令。