Created
December 30, 2021 21:55
-
-
Save xpepper/51010329cddb4efd82b266e28d4d23c3 to your computer and use it in GitHub Desktop.
A shell script to execute a command on a vagrant machine (e.g. ./asvagrant.sh ls)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
relativeDir="" | |
while [[ ! -d ".vagrant" ]]; do | |
if [[ "$(pwd)" == "/" ]]; then | |
echo "Not a valid path" | |
exit | |
fi | |
relativeDir="${PWD##*/}/$relativeDir" | |
cd .. | |
done | |
ssh -t vagrant@localhost -p 2222 -i ".vagrant/machines/default/virtualbox/private_key" "shopt -s expand_aliases; source /etc/profile.d/env.sh; source ~/.bash_aliases; cd /vagrant/$relativeDir; eval $@" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment