#
# shellcheck shell=bash
#
# in-1.cc - instant dev tools for your current shell
#
# Usage:
# source <(curl -sL in-1.cc) TOOL[=VERSION]... # bash / zsh
# curl -sL in-1.cc | source - TOOL[=VERSION]... # fish
#
# For example:
# source <(curl -sL in-1.cc) rust node
#
# Docs: https://in-1.cc/home/
# Source: https://github.com/in-1-cc/in-1
#
# This installs the requested tools under a temp dir and sets up
# PATH, MANPATH, completions and tool env vars in your current shell
# for the duration of the shell session.
test -n "$BASH_VERSION$ZSH_VERSION" && eval '
_in1_boot() {
local pin=${IN1_VERSION:-8555092}
local tmp=${TMPDIR:-/tmp}
local root=${IN1_ROOT:-${tmp%/}/in-1}
local repo=${IN1_REPO:-https://github.com/in-1-cc/in-1}
local shell=bash out
[ -n "${ZSH_VERSION-}" ] && shell=zsh
command -v git >/dev/null 2>&1 || {
echo "in-1: git is required" >&2
return 1
}
mkdir -p "$root" || return 1
if [ ! -d "$root/in-1" ]; then
git clone -q "$repo" "$root/in-1" || {
echo "in-1: failed to clone $repo" >&2
return 1
}
fi
# Use the in-1 version this script was published with, unless the
# version token was never stamped (running from a working copy)
if [ "$pin" != "@IN1_VERSION""@" ]; then
git -C "$root/in-1" rev-parse -q --verify "$pin^{commit}" \
>/dev/null 2>&1 ||
git -C "$root/in-1" fetch -q --tags origin 2>/dev/null
git -C "$root/in-1" checkout -q "$pin" || {
echo "in-1: failed to checkout in-1 version $pin" >&2
return 1
}
fi
out=$(bash "$root/in-1/bin/in-1" --env "$shell" "$@") || return 1
eval "$out"
}
_in1_boot "$@"
_in1_status=$?
unset -f _in1_boot
if [ "$_in1_status" -eq 0 ]; then
unset _in1_status
return 0
else
unset _in1_status
return 1
fi
'
test -n "$FISH_VERSION" && eval '
function _in1_boot
set -l pin "$IN1_VERSION"
test -n "$pin"; or set pin "@IN1_VERSION""@"
set -l tmp "$TMPDIR"
test -n "$tmp"; or set tmp /tmp
set -l root "$IN1_ROOT"
test -n "$root"; or set root (string trim -r -c / -- $tmp)/in-1
set -l repo "$IN1_REPO"
test -n "$repo"; or set repo https://github.com/in-1-cc/in-1
command -q git; or begin
echo "in-1: git is required" >&2
return 1
end
mkdir -p $root; or return 1
if not test -d $root/in-1
git clone -q $repo $root/in-1; or begin
echo "in-1: failed to clone $repo" >&2
return 1
end
end
if test "$pin" != "@IN1_VERSION""@"
git -C $root/in-1 rev-parse -q --verify "$pin^{commit}" \
>/dev/null 2>&1
or git -C $root/in-1 fetch -q --tags origin 2>/dev/null
git -C $root/in-1 checkout -q $pin; or begin
echo "in-1: failed to checkout in-1 version $pin" >&2
return 1
end
end
set -l envfile (mktemp)
if bash $root/in-1/bin/in-1 --env fish $argv > $envfile
source $envfile
rm -f $envfile
else
rm -f $envfile
return 1
end
end
_in1_boot $argv
set -l _in1_status $status
functions -e _in1_boot
return $_in1_status
'
echo "ERROR: in-1.cc requires bash, zsh or fish" >&2
false
# vim: ft=sh: