Skip to content

Instantly share code, notes, and snippets.

@mikerenfro
Created April 21, 2020 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikerenfro/3a01d5ac976862d51f6ebb5c217d6948 to your computer and use it in GitHub Desktop.
Save mikerenfro/3a01d5ac976862d51f6ebb5c217d6948 to your computer and use it in GitHub Desktop.
Script to download busybox and shellshare for a Windows system running mays (as used in Git bash)
#!/bin/bash
#
# if file is accessible from the web:
# /bin/bash -c "$(curl -fsSL https://location.to/file/get_shellshare)"
pushd () {
command pushd "$@" > /dev/null
}
popd () {
command popd "$@" > /dev/null
}
# Download script
if [[ ! -x /usr/bin/script ]]; then
mkdir busybox
pushd busybox
curl -sO http://repo.msys2.org/msys/x86_64/busybox-1.23.2-1-x86_64.pkg.tar.xz
tar Jxf busybox-1.23.2-1-x86_64.pkg.tar.xz
cp usr/bin/busybox.exe /usr/bin/ 2> /dev/null
if [[ $? -gt 0 ]]; then
# git may have been installed system-wide, and it's not writable unless run as administrator.
mkdir -p ~/.bin
cp usr/bin/busybox.exe ~/.bin/ 2> /dev/null
ln -s ~/.bin/busybox.exe ~/.bin/script.exe
echo 'export PATH="${HOME}/.bin/:${PATH}"' >> ~/.bash_profile
echo 'Please, close this shell and open a new one for the changes to take effect.'
else
ln -s /usr/bin/busybox.exe /usr/bin/script.exe
fi
popd
rm -rf busybox
fi
# Download shellshare
if [[ ! -f shellshare ]]; then
curl -sLO shellshare https://get.shellshare.net
fi
hash python 2>/dev/null || { echo >&2 "Install python and make sure is accessible by gitbash."; exit 1; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment