我正在尝试创建别名,我可以在运行VM时随时在Vagrant中使用这些别名。我在网上找到了几个关于它的消息来源,但无法让它发挥作用。我尝试在同步文件夹中创建一个.bash_profile,但这不起作用。我注意到如果我运行命令alias name =“command”这将起作用,但仅适用于当前会话。有人知道怎么做吗?我正在使用macOS。谢谢你的帮助!
这是我的Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
unless Vagrant.has_plugin?("vagrant-vbguest")
warn "\nWARNING: The vagrant-vbguest plugin should be installed or your shared folders might not mount properly!"
warn "You can do this by running the command 'vagrant plugin install vagrant-vbguest'.\n\n"
end
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "pype_vm"
config.vm.box_url = "https://.../pype_vm.json"
config.vm.network "private_network", ip: ""
config.vm.boot_timeout = 600
config.vm.provider "virtualbox" do |v|
# This forces VirtualBox to use the host's DNS resolver instead of
# VirtualBox's
v.customize ["modifyvm", :id, "", "on"]
# This enables the PAE/NX option, which resolved at least one user's
# issues with the VM hanging on boot
v.customize ["modifyvm", :id, "--pae", "on"]
# The RHEL VM was created with 2GB of memory to facilitate provisioning,
# but this is causing issues with certain workstations. This reduces
# the amount of memory allocated to the VM but should not impact development
# performance. The number is in MB and can be increased if desired.
v.memory = 1024
end
# Share an additional folder to the guest VM.
config.vm.synced_folder File.dirname(__FILE__), "/pype"
end
答案 0 :(得分:0)
详细信息取决于正在运行的guest虚拟机的具体情况,但有些注意事项:
vagrant ssh
的默认用户帐户处于有效状态,请确保您要覆盖的所有点文件都已复制到/home/vagrant
。.bashrc
,请确保使用交互式标记启动远程shell(如果这是真的,echo $-
将包含i
)。.bash_profile
,请确保远程shell作为登录shell启动(如果这是真的,echo $-
将包含l
)。