Skip to content

Instantly share code, notes, and snippets.

@vbrozik
Created July 6, 2022 14:58
Show Gist options
  • Save vbrozik/2dff5d7a235484388a8e5d460d979c2e to your computer and use it in GitHub Desktop.
Save vbrozik/2dff5d7a235484388a8e5d460d979c2e to your computer and use it in GitHub Desktop.
wslu partial installation
#!/bin/sh
# Install parts of wslu (currently only wslview) as independent files to avoid
# installing the huge amount of dependencies.
# In Ubuntu 20.04-22.04 the dependecies are: 61 packages, 177 MB disk space
# Václav Brožík 2022-07
# public-domain
# references:
# https://github.com/wslutilities/wslu
# https://wslutiliti.es/wslu/
install_prefix=/usr/local
branch_url=https://raw.githubusercontent.com/wslutilities/wslu/dev/master
script_headers="$branch_url"/src/wslu-header
wslview_body="$branch_url"/src/wslview.sh
wslu_conf="$branch_url"/src/etc/conf
# browser registration:
# ---------------------
# wslview -r
# registers the following executable names using update-alternatives:
# www-browser, x-www-browser
# applications using wslview:
# ---------------------------
# * without registration:
# * gh
# * after registration (wslview -r):
# * jupyter-lab
errexit () {
printf '%s\n' "$*" Exiting. >&2
exit 1
}
cat_url () {
curl -fsSL "$@"
}
version="$(cat_url "$branch_url/VERSION")"
cat_url "$script_headers" "$wslview_body" |
sed -e "s%PREFIXPLACEHOLDER%$install_prefix%" \
-e "s/VERSIONPLACEHOLDER/$version/" |
sudo dd of="$install_prefix/bin/wslview" ||
errexit Failed to write wslview.
sudo chmod -v a+x "$install_prefix/bin/wslview" ||
errexit Failed to chmod wslview.
sudo mkdir -vp "$install_prefix/share/wslu" ||
errexit Failed to create directory.
cat_url "$wslu_conf" |
sudo dd of="$install_prefix/share/wslu/conf" ||
errexit Failed to write conf.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment