bb-import is a single, self-contained shell script. You have 4 options for installation:
The easiest way to install bb-import is to use the Automagic Online Installer.
All you need to do is execute the following line of code in your terminal:
bash <(curl -sfLS https://raw.githubusercontent.com/bash-bits/bb-import/master/install.sh)This script will automagically install BB-Import on your local machine in SHEBANG mode, into a directory under your HOME directory, and will ensure that all the relevant directories are created. It will also ensure bb-import itself has all the infrastructure necessary to take advantage of the automatic-update functionality coming in the next version.
If you want to change any parameters, you can do so, of course - but you're going to have to clone a copy of the repo to do it (see below).
The process documented here is basically the manual version of using the Automagic Online Installer.
Technically, you can install this script anywhere on your $PATH - but to take advantage of the caching mechanisms, you'll need to do the following:
(You can either copy and paste each line to your terminal, or copy one whole block of code at a time and paste it into your terminal)
First we're going to borrow a few snippets of code from the importer to make life easier:
location="https://raw.githubusercontent.com/bash-bits/bb-import/master/src/bb-import.sh"
cfgFile="https://raw.githubusercontent.com/bash-bits/bb-import/master/src/bb-import.ini"
installPath="/usr/local/bin/bb-import"
url="bb-import"
cacheDir="$HOME/.bb"
cache="$cacheDir/bb-import.sh"
cfgDir="$cache/cfg"
cfgPath="$cfgDir/$cfgFile"
envPath="$cfgDir/$envFile"
urlPath="$(echo "$url" | sed 's/\:\///')"
cachePath="$cache/links/$urlPath"
dir="$(dirname "$urlPath")"
linkDir="$cache/links/$dir"
echo "Creating directories:"
echo " $cfgDir"
echo " $linkDir"
echo " $cache/data"
echo " $cache/locations/$dir"
mkdir -p "$cfgDir" "$linkDir" "$cache/data" "$cache/locations/$dir" >&2 || returntmpFile="$cachePath.tmp"
tmpHeader="$cachePath.header"
locFile="$cache/locations/$urlPath"
echo "Downloading $location -> $tmpFile"
curl -sfLS --netrc-optional --output "$tmpFile" "$location" || { r=$?; echo "Failed to download: $location" >&2; rm -f "$tmpFile"; return "$r"; }
sudo cp "$tmpFile" "$installPath" || { r=$?; echo "Failed to install bb-import in $installPath"; return "$r"; }
sudo chmod +x "$installPath"
echo "Resolved location '$url' -> '$location'"
echo "$location" > "$locFile"
echo
echo "Downloading $cfgFile -> $cfgPath"
curl -sfLS --netrc-optional --output "$cfgPath" "$cfgFile" || { r=$?; echo "Failed to download: $cfgFile" >&2; rm -f "$cfgPath"; return "$r"; }hash="$(sha1sum < "$tmpFile" | { read -r first rest; echo "$first"; })" || return
echo "Calculated hash '$url' -> '$hash'"
hashFile="$cache/data/$hash"
[[ -f "$hashFile" ]] && { rm -f "$tmpFile" || return; } || { mv "$tmpFile" "$hashFile" || return; }
[[ "${linkDir:0-1}" == "." ]] && linkDir="${linkDir:0:${#linkDir}-2}"
cacheStart="$(( "${#cache}" + 1 ))" || return
relative="$(echo "$linkDir" | awk '{print substr($0, '"$cacheStart"')}' | sed 's/\/[^/]*/..\//g')data/$hash" || return
printf "import: Creating symlink " >&2
ln -fs${IMPORT_DEBUG:+v} "$relative" "$cachePath" >&2 || return
[ -n "${IMPORT_TRACE-}" ] && echo "$location" >> "$IMPORT_TRACE"
echo "Successfully downloaded '$url' -> '$hashFile'"
echo "SYMLINK: '$relative' -> '$cachePath'"
echo "Creating path file ..."
echo "PATH=\"$cacheDir:\$PATH\"" > "$cacheDir/bb-path.sh"
if [[ "$SHELL" =~ .*bash.* ]]; then
echo -n "Moving path file to /etc/profile.d directory ... "
if sudo cp "$cacheDir/bb-path.sh" /etc/profile.d/bb-path.sh; then echo "DONE"; writePath=1; else echo "FAIL"; writePath=0; fi
fiIf you think you might need to change a few options or modify some code before you install bb-import, then this is the option for you.
Simply clone the repo, make your modifications, enter the root directory, and run the installer:
git clone git@github.com:bash-bits/bb-import
... <tinker> ...
cd bb-import
bash install.shAnd if you're one of those people who are absolutely determined to do things the hard way, you can download the latest release package from GitHub so that you can install it manually to your own specifications.
Step 1 - DOWNLOAD THE LATEST PACKAGE HERE
Step 2 - Inflate the archive
Step 3 - Enter the root directory of the repository
Step 4 - bash install.sh