繁体   English   中英

如何在Vagrant中使用别名

[英]How to use aliases in Vagrant

我正在尝试创建可在运行VM时随时在Vagrant中使用的别名。 我在网上找到了一些有关它的信息,但无法正常工作。 我尝试在已同步的文件夹中制作一个.bash_profile,但这没有用。 我注意到,如果我运行命令别名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

详细信息取决于正在运行的来宾的具体情况,但请注意以下几点:

  • 假设默认用户帐户对vagrant ssh是活动的,请确保将要覆盖的所有点文件都复制到/home/vagrant
  • 如果覆盖.bashrc ,请确保使用交互标志启动远程外壳程序(如果为true,则echo $-将包含i )。
  • 如果覆盖.bash_profile ,请确保将远程外壳程序作为登录外壳程序启动(如果为true,则echo $-将包含l )。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM