Reputation: 1062
I'm trying to add some additional lines to .bashrc in my home directory from the provisioning shell script when launching a new instance with Vagrant.
In the shell script I have:
set -x
sudo apt-get update
sudo apt-get install vim
echo "source /usr/local/share/chruby/chruby.sh">> ~/.bashrc
echo "source /usr/local/share/chruby/auto.sh">> ~/.bashrc
However after completion nothing has been written to .bashrc.
This is a cut down version of the full script the intention of which is to install Ruby/Rails.
Upvotes: 11
Views: 7667
Reputation: 137
Try this for your last 2 lines - it should give you exactly what you need.
echo "source /usr/local/share/chruby/chruby.sh" >> /home/vagrant/.bashrc
echo "source /usr/local/share/chruby/auto.sh" >> /home/vagrant/.bashrc
Upvotes: -2
Reputation: 1701
You need to give the full path to the file.
E.g.
echo "source /usr/local/share/chruby/chruby.sh" >> /home/vagrant/.bashrc
Upvotes: 26
Reputation: 4551
Add these lines to .bashrc
if [ -f /usr/local/share/chruby/chruby.sh ]; then
. /usr/local/share/chruby/chruby.sh
fi
It will textually include the script into .bashrc and execute it when opening a new shell.
Upvotes: -1