我正在学习Vagrant和Virtualbox,现在需要在我的hosts文件中添加一行(Windows系统)。
echo "test" >> c:/windows/system32/drivers/etc/hosts
我在想是否可以创建一个快捷方式到c:/windows/system32/drivers/etc/hosts文件,这样我就可以在任何地方的shell中使用了。
我正在学习Vagrant和Virtualbox,现在需要在我的hosts文件中添加一行(Windows系统)。
echo "test" >> c:/windows/system32/drivers/etc/hosts
我在想是否可以创建一个快捷方式到c:/windows/system32/drivers/etc/hosts文件,这样我就可以在任何地方的shell中使用了。
[System.Environment]::SetEnvironmentVariable('Youralias','c:/windows/system32/drivers/etc/hosts','Machine)
然后使用
访问它。$env:YourAlias
从PowerShell中...如果你想从CMD访问它
%Youralias%
应该能够正常工作。
在您的主目录(Windows)中,您可以创建一个.bash_profile文件并指定别名。 前往您的主目录
cd ~
touch .bash_profile && vim .bash_profile
通过添加以下行来添加新的别名
alias testfolder="cd /c/testfolder"
保存并关闭你的编辑器。
由于某种原因,只有在我运行以下命令后它才起作用。
source .bash_profile