url_busybox_vi_heroku="https://gist.githubusercontent.com/Golit/85a2ae4b9adabc07d1d924dfd9da6137/raw/busybox-vi-heroku.sh"
curl -s -L -o busybox-vi-heroku.sh ${url_busybox_vi_heroku}
[ "$(cat busybox-vi-heroku.sh | grep -v "^#\|^$" | sha256sum)" == "7fc7424ec7f5dcb962a02cdf56dd24daf709fc805e2d0f1bbc6d7110b73a9b73 -" ] && bash ./busybox-vi-heroku.sh
# Since /app/bin is in the $PATH you can launch vi like this:
vi
Last active
January 12, 2019 22:45
-
-
Save Golit/85a2ae4b9adabc07d1d924dfd9da6137 to your computer and use it in GitHub Desktop.
Edit files on heroku with busybox vi
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
#!/bin/bash | |
# Downloads busybox to run vi on heroku | |
# Tested on heroku-16 | |
# Fetch the version of busybox in the alpine repository | |
VERSION=$(curl -s -L http://dl-cdn.alpinelinux.org/alpine/latest-stable/main/x86_64/APKINDEX.tar.gz | tar -xzOf - APKINDEX | grep -A 12 -B 1 "^P:busybox-static$" | grep "^V:" | cut -c3-) | |
# Download busybox-static from the alpinelinux repository and extract the binary into /app/bin | |
# if the download fails visit the repository to check if the filename has changed | |
# The Output: | |
# tar: Ignoring unknown extended header keyword 'APK-TOOLS.checksum.SHA1' | |
# is not an error therefore we redirect it to /dev/null | |
URL_BUSYBOX_APK="http://dl-cdn.alpinelinux.org/alpine/latest-stable/main/x86_64/busybox-static-${VERSION}.apk" | |
curl -s -L ${URL_BUSYBOX_APK} | tar -C /app -xzf - 2> /dev/null || (echo "Downloading busybox from ${URL_BUSYBOX_APK} failed!"; exit 1) | |
# create symbolic link | |
ln -s /app/bin/busybox.static /app/bin/vi | |
# Now you are ready to edit your files | |
# run: $ vi | |
# cat busybox-vi-heroku.sh | grep -v "^#\|^$" | sha256sum | |
# sha256sum:7fc7424ec7f5dcb962a02cdf56dd24daf709fc805e2d0f1bbc6d7110b73a9b73 - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment