Skip to content

Instantly share code, notes, and snippets.

@brbsix
Created September 17, 2020 07:01
Show Gist options
  • Save brbsix/999c3d4a4a881400f6c8ee5417a66a15 to your computer and use it in GitHub Desktop.
Save brbsix/999c3d4a4a881400f6c8ee5417a66a15 to your computer and use it in GitHub Desktop.
Install shellcheck on Termux
#!/bin/bash
#
# Install shellcheck
set -euo pipefail
# resynchronize the package index
apt-get -qq update
# install QEMU Linux user mode emulator (and jq)
apt-get -qqy install curl jq qemu-user-x86_64 wget
ARCHIVE_URL=$(curl -H 'Accept: application/vnd.github.v3+json' https://api.github.com/repos/koalaman/shellcheck/releases/latest 2>/dev/null | jq -r '.assets[] | select(.name | contains("linux.x86_64")) | .browser_download_url')
ARCHIVE_PATH=${ARCHIVE_URL##*/}
# create and enter temporary directory
tempdir=$(mktemp --directory --tmpdir shellcheck.XXXXXX)
cd "$tempdir"
# download archive
wget -q "$ARCHIVE_URL"
# extract binary from archive
tar xJf "$ARCHIVE_PATH" --no-anchored --strip-components=1 shellcheck
# install x86_64 binary
install -D -m 700 -t ~/.local/libexec/ ./shellcheck
# create laumcher script
cat <<EOF > launcher
#!/data/data/com.termux/files/usr/bin/sh
exec /data/data/com.termux/files/usr/bin/qemu-x86_64 /data/data/com.termux/files/home/.local/libexec/shellcheck "\$@"
EOF
# install launcher
install -D -m 700 -T ./launcher ~/.local/bin/shellcheck
@tathastu871
Copy link

cd $HOME
wget https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.aarch64.tar.xz
tar xvf shellcheck-stable.linux.aarch64.tar.xz
rm shellcheck-stable.linux.aarch64.tar.xz
cd shellcheck-stable
cp shellcheck $PREFIX/bin
echo 'alias shellcheck="proot -0 shellcheck"' >> $PREFIX/etc/bash.bashrc
echo 'alias vi="proot -0 vi"' >> $PREFIX/etc/bash.bashrc
rm -rf $HOME/shellcheck-stable
shellcheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment