-
-
Notifications
You must be signed in to change notification settings - Fork 24
feat: add installation script #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Chaitanyabsprip
wants to merge
5
commits into
arl:main
Choose a base branch
from
Chaitanyabsprip:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d889719
feat: add installation script
Chaitanyabsprip 78635ec
feat(install): ask install path as an envvar
Chaitanyabsprip ae7894d
feat: add help command to installation script
Chaitanyabsprip b2601bb
docs(install): say that INSTALL_PATH is required
Chaitanyabsprip 31413d5
fix(install): should exit early if curl is not found
Chaitanyabsprip File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/sh | ||
|
||
_have() { type "$1" >/dev/null 2>&1; } | ||
|
||
help() { | ||
cat <<EOF | ||
Usage: ${0##*/} [options] [version] | ||
|
||
Options: | ||
-h, --help Show this help message and exit. | ||
|
||
Arguments: | ||
version Specify the version of gitmux to install. If not provided, the latest version will be installed. | ||
|
||
Environment Variables: | ||
INSTALL_PATH Specify the directory where gitmux should be installed. Required | ||
|
||
Description: | ||
This script installs the gitmux tool, which provides Git status information in the tmux status line. | ||
It automatically detects the system architecture and downloads the appropriate version of gitmux. | ||
|
||
Examples: | ||
INSTALL_PATH=/usr/local/bin ${0##*/} Install the latest version of gitmux to /usr/local/bin. | ||
INSTALL_PATH=/usr/local/bin ${0##*/} v0.7.0 Install version 0.7.0 of gitmux to /usr/local/bin. | ||
|
||
EOF | ||
} | ||
|
||
gh_install() { | ||
ver="$1" | ||
repo='arl/gitmux' | ||
[ -z "$ver" ] && { | ||
latest="https://api.github.com/repos/$repo/releases/latest" | ||
ver=$(curl -sS "$latest" | grep tarball_url | sed 's>.*: "\(.*\)".*>\1>') && test -n "$ver" | ||
ver=${ver##*/} | ||
} | ||
tarname='' | ||
archi=$(uname -sm) | ||
case "$archi" in | ||
Darwin\ arm64) tarname="gitmux_${ver}_macOS_arm64.tar.gz" ;; | ||
Darwin\ x86_64) tarname="gitmux_${ver}_macOS_amd64.tar.gz" ;; | ||
Linux\ aarch64*) tarname="gitmux_${ver}_linux_arm64.tar.gz" ;; | ||
Linux\ *64) tarname="gitmux_${ver}_linux_amd64.tar.gz" ;; | ||
*) echo "Unsupported architecture" && return 1 ;; | ||
esac | ||
tmpdir="$(mktemp -d)" | ||
cd "$tmpdir" || : | ||
curl -sSLO "https://github.com/$repo/releases/download/$ver/$tarname" | ||
tar -xf gitmux*.tar.gz && | ||
mv gitmux "${INSTALL_PATH}" | ||
[ -d "$tmpdir" ] && rm -rf "$tmpdir" | ||
} | ||
|
||
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then help && exit 0; fi | ||
|
||
! _have curl && echo "This script depends on curl" && exit 1 | ||
[ -z "$INSTALL_PATH" ] && echo "Please set the INSTALL_PATH envvar to specify installation directory" && exit 1 | ||
|
||
echo "Installing gitmux..." | ||
if gh_install "$@"; then | ||
echo "Successfully installed gitmux" | ||
else | ||
echo "Could not install gitmux" && exit 1 | ||
fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.