我不明白为什么我在Vagrantfile shell配置脚本中的别名定义不起作用。
这是我的一部分Vagrantfile:
config.vm.provision "shell", inline: <<-SHELL
# this works
#echo 'alias pa="php artisan"' >> ~/.bash_aliases && source ~/.bash_aliases
# this doesn't
alias pa="php artisan"
# in order to be able to do this
pa migrate --seed
SHELL
如果我通过SSH连接到客户机并创建一个别名w/ alias=“command”,我就可以立即使用该命令。但是在shell脚本中做同样的事情是行不通的。
我错过了什么?
1条答案
按热度按时间czfnxgou1#
正如Fravadona所指出的,您不能在非交互式shell中使用别名。你可以创建一个函数。所以,这个解决方案是有效的: