summaryrefslogtreecommitdiffstatshomepage
path: root/scripts/.local
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2023-02-13 15:31:22 -0600
committerToby Vincent <tobyv13@gmail.com>2023-02-13 15:31:22 -0600
commitcb4d795bf5944a6632b204659915ff2d9628b2d0 (patch)
tree2472e27e056468281ac91e110a48760cd50389e0 /scripts/.local
parent17fc297bb9f4ef334c72b3493f0eb517e4d3a2a8 (diff)
chore: remove unused scripts
Diffstat (limited to 'scripts/.local')
-rwxr-xr-xscripts/.local/bin/git-split.sh208
-rwxr-xr-xscripts/.local/bin/init-git.sh193
-rwxr-xr-xscripts/.local/bin/init-latex.sh11
-rwxr-xr-xscripts/.local/bin/install-crate.sh235
-rwxr-xr-xscripts/.local/bin/mega-dl.sh121
-rwxr-xr-xscripts/.local/bin/td.sh151
6 files changed, 0 insertions, 919 deletions
diff --git a/scripts/.local/bin/git-split.sh b/scripts/.local/bin/git-split.sh
deleted file mode 100755
index ecb2b3a..0000000
--- a/scripts/.local/bin/git-split.sh
+++ /dev/null
@@ -1,208 +0,0 @@
-#!/usr/bin/env bash
-
-TEMP=$(getopt -o hvdymu:r: --long help,verbose,debug,submodule,remote:,username:,visibility: \
- -n 'javawrap' -- "$@")
-
-if [ $? != 0 ]; then
- echo "Terminating..." >&2
- exit 1
-fi
-
-if ! git rev-parse --is-inside-work-tree &>/dev/null; then
- echo "Must be run inside a git repository" >&2
- exit 1
-fi
-
-eval set -- "$TEMP"
-
-SCRIPT="$(basename $0)"
-ARTIFACTS=(".gitignore" ".gitattributes" ".vscode" "LICENSE")
-VERBOSE=false
-DEBUG=false
-CONFIRMED=false
-SUBMODULE=false
-REPO=$(git rev-parse --show-toplevel)
-USERNAME="$(git config user.username)"
-REMOTE=
-VISIBILITY="--public"
-
-read -r -d '' USAGE <<-EOF
-USAGE: $SCRIPT [OPTIONS]
-
-OPTIONS:
- -h, --help Show this message
- -v, --verbose Show more output
- -d, --debug NOT IMPLEMENTED
- -y, --confirm Do not prompt for confirmation
- -m, --submodule
- Migrate directory in original repository to submodule
-
- -u, --username=<user/repo>
- Github username. Can be used instead of remote to dynamically name
- the repositories. If --username and --remote are both ommited, defaults
- to $(git config user.username)
-
- -r, --remote=<user/repo>
- Github remote, defaults to ${username}/${directory}
-
- --private
- Create the new remote repository as private. It is created
- as public if ommited
-
-ARGS:
- <DIRECTORY>... Directory to split out of original repository,
- defaults to current directory
-EOF
-
-while true; do
- case "$1" in
- -h | --help)
- echo "$USAGE"
- exit 0
- ;;
- -v | --verbose)
- VERBOSE=true
- shift
- ;;
- -d | --debug)
- DEBUG=true
- shift
- ;;
- -y)
- CONFIRMED=true
- shift
- ;;
- -m | --submodule)
- SUBMODULE=true
- shift
- ;;
- -u | --username)
- USERNAME="$2"
- shift 2
- ;;
- -r | --remote)
- REMOTE="$(basename $(dirname ${2#"git@github.com:"}))/$(basename ${2#"git@github.com:"})"
- shift 2
- ;;
- --public | --private)
- VISIBILITY="$1"
- shift
- ;;
- --)
- shift
- break
- ;;
- *)
- break
- ;;
- esac
-done
-
-DIRECTORY="${1:-$(realpath --relative-to="$REPO" .)}"
-
-if [ ! -d "${REPO}/${DIRECTORY}" ]; then
- echo "ERROR: Directory does not exist." >&2
- echo "$USAGE"
- exit 1
-fi
-
-if [ -z "$REMOTE" ]; then
- if [ -z "$USERNAME" ]; then
- echo "ERROR: No remote provided and user.username was not set." >&2
- echo "$USAGE"
- exit 1
- else
- REMOTE="${USERNAME}/${DIRECTORY}"
- fi
-fi
-
-set -e
-
-cd $REPO
-
-git subtree split -P $DIRECTORY -b $DIRECTORY
-
-cd "$(mktemp -d)"
-
-git init && git pull $REPO $DIRECTORY && git branch -M main
-
-for f in "${ARTIFACTS[@]}"; do
- if [[ ! -e "./${f}" && -e "${REPO}/${f}" ]]; then
- printf '%s\n' "Copying ${f} to new repository..."
- cp -r "${REPO}/${f}" ./
- fi
-done
-
-git add -A && git commit -m "split out $DIRECTORY into submodule"
-
-# TODO check if remote already exists
-if command -v gh &>/dev/null; then
- yes "n" | gh repo create --confirm "${REMOTE}" "${VISIBILITY}"
-else
- printf '%s\n' 'gh cli tool could not be found. Explicitly adding git remote to your local repository.'
-
- git remote add origin https://github.com/${REMOTE}
-fi
-
-set +e
-
-git push -u origin main
-
-if [ $? -ne 0 ]; then
- printf '\n%s\n' 'Verify/create the remote repository and push to it with the following command: '
- printf '\n\t%s%s%s\n\n' '`cd ' "$(pwd)" ' && git push -u origin main`'
-
- printf '\t%s\n' \
- '*********************************************************************************' \
- '* The new repository was created in a temp directory! *' \
- '* If the local repository is not pushed to remote, it will be lost on reboot. *' \
- '*********************************************************************************'
-else
- tempdir="$(pwd)"
- cd "$REPO"
- rm -rf "$tempdir"
-fi
-
-# Migrate to submodule
-
-if [ "$SUBMODULE" != true ]; then
- exit 0
-fi
-
-# TODO fix and remove warning
-
-printf 'Migrating the original subdirectory to submodule.\n'
-
-if [ "$QUIET" != true ]; then
- printf '\t%s\n' \
- '*************************************************************************************' \
- '* THIS IS NOT TESTED AND HAS A POSSIBLY OF DATA LOSS! *' \
- '* *' \
- '* This runs `git rm -rf` and `rm -rf` on the original subdirectory. *' \
- '* Double check you succesfully migrated the subdirectory to the new repository. *' \
- '*************************************************************************************'
-fi
-
-if [ "$CONFIRMED" != true ]; then
- read -p "Proceed? (Y/n) " -n 1 -r
- printf '\n'
- if [[ $REPLY =~ ^[Yy]$ ]]; then
- CONFIRMED=true
- else
- [[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
- fi
-fi
-
-cd $REPO
-
-git rm -rf $DIRECTORY
-rm -rf $DIRECTORY
-
-git submodule add git@github.com:$REMOTE $DIRECTORY
-git submodule update --init --recursive
-
-git commit -m "split out $DIRECTORY into submodule"
-
-if [ $? -ne 0 ]; then
- printf '%s\n' 'Submodule succesfully added. Be sure to `git push -u origin main` after verifing the migration.'
-fi
diff --git a/scripts/.local/bin/init-git.sh b/scripts/.local/bin/init-git.sh
deleted file mode 100755
index 0a45b90..0000000
--- a/scripts/.local/bin/init-git.sh
+++ /dev/null
@@ -1,193 +0,0 @@
-#!/usr/bin/env bash
-
-# Global
-SCRIPT="$(basename $0)"
-SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
-GITATTRIBUTES_URL="https://gist.githubusercontent.com/tobyvin/70f3671c76016063594ea45edbb97094/raw"
-
-# Defaults
-VERBOSE=0
-QUIET=0
-INTERACTIVE=0
-TEMPLATE="visualstudiocode"
-LICENSE="mit"
-
-# Usage output
-read -r -d '' USAGE <<USAGE
-USAGE: $SCRIPT [OPTIONS] <IGNORE_TEMPLATE>
-
-OPTIONS:
- -h, --help Show this message
- -v, --verbose Show more output
- -q, --quiet Suppress all output
- -i, --interactive Run command interactivly
-
- -l, --license [LICENSE_ID]
- Specify which license to generate. Defaults to '$LICENSE'
-
- -t, --template [IGNORE_TEMPLATE,...]
- Project template(s) used when generating the .gitignore file. It
- can also be a comma seperated list or templates. Use '-t list' to
- see available templates. Defaults to '$TEMPLATE'
-USAGE
-
-# Options
-SHORT=hvqil:t:
-LONG=help,verbose,quiet,interactive,license:,template:
-
-# Test getopt
-getopt --test 2>/dev/null
-if [[ $? -ne 4 ]]; then
- read -r -d '' message <<EOF
-GNU's enhanced getopt is required to run this script
-You can usually find this in the util-linux package
-On MacOS/OS X see homebrew's package: http://brewformulas.org/Gnu-getopt
-For anyone else, build from source: http://frodo.looijaard.name/project/getopt
-EOF
- echo "$message" >&2
- exit 1
-fi
-
-# Parse options
-TEMP=$(getopt \
- --options ${SHORT} \
- --longoptions ${LONG} \
- --name ${SCRIPT} \
- -- "$@")
-
-# Exit on failed getopt
-if [ $? != 0 ]; then
- echo "Error in getopt. Terminating..." >&2
- exit 1
-fi
-
-eval set -- "${TEMP}"
-unset TEMP
-
-while [[ $# -gt 0 ]]; do
- case "$1" in
- -h | --help)
- echo "$USAGE"
- exit 0
- ;;
- -v | --verbose)
- VERBOSE=1
- shift
- ;;
- -q | --quiet)
- QUIET=1
- shift
- ;;
- -i | --interactive)
- INTERACTIVE=1
- shift
- ;;
- -l | --license)
- LICENSE="$2"
- shift 2
- ;;
- -t | --template)
- TEMPLATE="$2"
- shift 2
- ;;
- --)
- shift
- break
- ;;
- *) break ;;
- esac
-done
-
-VALID_TEMPLATES=$(curl -L -s "https://www.toptal.com/developers/gitignore/api/list")
-
-validate-template() {
- local template="$1"
- local templates="$2"
- if [[ ",$2," == *",$template,"* ]]; then
- [ "$QUIET" != 1 ] && printf "'%s' is already added.\n" "$template" >&2
- return 1
- elif ! [[ $VALID_TEMPLATES =~ "$template" ]]; then
- [ "$QUIET" != 1 ] && printf "'%s' is not a valid template.\n" "$template" >&2
- return 1
- else
- [ "$VERBOSE" == 1 ] && printf "Added template: %s\n" "$template" >&2
- return 0
- fi
-}
-
-get-gitignore() {
- local templates=''
- IFS=',' read -ra input <<<"$1"
-
- for template in "${input[@]}"; do
- if validate-template "$template" "$templates"; then
- templates+="${template},"
- fi
- done
-
- echo ${templates%?}
-}
-
-get-gitignore-interactive() {
- local templates=''
-
- while true; do
- read -p 'Input gitignore template(s): ' -i "$1" readInput
- echo ""
-
- IFS=', ' input=$readInput
- [ -z "$input" ] && break
- if [[ "$input" == "list" ]]; then
- echo "$VALID_TEMPLATES" >&2
- else
- for template in $input; do
- if validate-template "$template" "$templates"; then
- templates+="${template},"
- fi
- done
- fi
- [ "$QUIET" != 1 ] && printf "\nTemplates: %s\n" "${templates%?}" >&2
- done
-
- echo "${templates%?}"
-}
-
-get-license() {
- licenseJson="$(curl -sH 'Accept: application/vnd.github.v3+json' https://api.github.com/licenses/$1)"
- # not_found='"message": "Not Found"'
- if [[ $licenseJson =~ '"message": "Not Found"' ]]; then
- [ "$QUIET" != 1 ] && printf "'%s' is not a valid license identifier.\n" "$LICENSE" >&2
- else
- echo $licenseJson | grep -oP '.*"body":\s*"\K.*(?=\s*",)' |
- tr '\n' '\0' | xargs -0 printf '%b\n' |
- sed "s/\\[year\\]/$(date +'%Y')/" |
- sed "s/\\[fullname\\]/$(git config --get user.name)/"
- fi
-}
-
-if [[ "$TEMPLATE" == "list" ]]; then
- echo "$VALID_TEMPLATES"
- exit 0
-fi
-
-if [ $INTERACTIVE -eq 0 ]; then
- gitignore_cmd=get-gitignore
-else
- gitignore_cmd=get-gitignore-interactive
-fi
-
-TEMPLATES=$($gitignore_cmd $TEMPLATE)
-
-# .gitignore
-[ "$VERBOSE" == 1 ] && printf "Creating .gitignore using: %s\n" "$TEMPLATES" >&1
-curl -L -s "https://www.toptal.com/developers/gitignore/api/${TEMPLATES}" >.gitignore
-
-# .gitattributes
-[ "$VERBOSE" == 1 ] && printf "Creating .gitattributes\n" >&1
-curl -sL "$GITATTRIBUTES_URL" >.gitattributes
-
-# LICENSE
-[ "$VERBOSE" == 1 ] && printf "Creating LICENSE using: %s\n" "$LICENSE" >&1
-get-license $LICENSE >LICENSE
-
-echo "$PWD"
diff --git a/scripts/.local/bin/init-latex.sh b/scripts/.local/bin/init-latex.sh
deleted file mode 100755
index 7b8125e..0000000
--- a/scripts/.local/bin/init-latex.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/env bash
-
-USER="tobyvin"
-GIST_ID="c94716d1106256e4ab0e27aed398a0a2"
-
-curl -Ls "https://gist.github.com/${USER}/${GIST_ID}/download" -o tempFile
-unzip -q tempFile
-rm -rf tempFile
-mv "${GIST_ID}-master" styles
-mv styles/template.tex "$(basename "$(pwd)").tex"
-mv styles/table.tex .
diff --git a/scripts/.local/bin/install-crate.sh b/scripts/.local/bin/install-crate.sh
deleted file mode 100755
index 1c1578a..0000000
--- a/scripts/.local/bin/install-crate.sh
+++ /dev/null
@@ -1,235 +0,0 @@
-#!/bin/sh
-
-# modified from https://github.com/japaric/trust/blob/gh-pages/install.sh.
-
-set -e
-
-help() {
- cat <<'EOF'
-Install a binary release of a Rust crate hosted on GitHub
-
-Usage:
- install-crate.sh [options]
-
-Options:
- -h, --help Display this message
- -q, --quiet Silence all output
- --git SLUG Get the crate from "https://github/$SLUG"
- -f, --force Force overwriting an existing binary
- --crate NAME Name of the crate to install (default <repository name>)
- --tag TAG Tag (version) of the crate to install (default <latest release>)
- --no-tag Do not tag between the crate and the target in the url
- --target TARGET Install the release compiled for $TARGET (default <`rustc` host>)
- --to LOCATION Where to install the binary (default ~/.cargo/bin)
- --completion
- Install all the completions
-
- --completion-bash DIR
- Install the bash completion scripts in DIR (default ~/.local/share/bash_completion.d)
-
- --completion-zsh DIR
- Install the zsh completion scripts in DIR (default ~/.local/share/zsh/site-functions)
-
- --completion-fish DIR
- Install the fish completion scripts in DIR (default ~/.config/fish/completions)
-EOF
-}
-
-say() {
- if [ ! $quiet ]; then
- echo "install-crate.sh: $1"
- fi
-}
-
-say_err() {
- say "$1" >&2
-}
-
-err() {
- if [ ! -z $td ]; then
- rm -rf $td
- fi
-
- say_err "ERROR $1"
- exit 1
-}
-
-need() {
- if ! command -v $1 >/dev/null 2>&1; then
- err "need $1 (command not found)"
- fi
-}
-
-is_opt() { case $1 in "--"*) true ;; *) false ;; esac }
-is_arg() { if [ "$1" ] && ! is_opt $1; then true; else false; fi; }
-
-quiet=false
-force=false
-no_tag=false
-completion_bash=false
-completion_zsh=false
-completion_fish=false
-comp_dir_bash="${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion/completions"
-comp_dir_zsh="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/site-functions"
-comp_dir_fish="${XDG_CONFIG_HOME:-$HOME/.config}/fish/completions"
-while test $# -gt 0; do
- case $1 in
- --quiet | -q)
- quiet=true
- ;;
- --crate)
- crate=$2
- shift
- ;;
- --force | -f)
- force=true
- ;;
- --git)
- git=$2
- shift
- ;;
- --help | -h)
- help
- exit 0
- ;;
- --tag)
- tag=$2
- shift
- ;;
- --no-tag)
- no_tag=true
- ;;
- --target)
- target=$2
- shift
- ;;
- --to)
- dest=$2
- shift
- ;;
- --completion)
- completion_bash=true
- completion_zsh=true
- completion_fish=true
- ;;
- --completion-bash)
- completion_bash=true
- if is_arg $2; then
- comp_dir_bash=$2
- shift
- fi
- ;;
- --completion-zsh)
- completion_zsh=true
- if is_arg $2; then
- echo "$2"
- comp_dir_zsh=$2
- shift
- fi
- ;;
- --completion-fish)
- completion_fish=true
- if is_arg $2; then
- comp_dir_fish=$2
- shift
- fi
- ;;
- *) ;;
-
- esac
- shift
-done
-
-# Dependencies
-need basename
-need curl
-need install
-need mkdir
-need mktemp
-need tar
-
-# Optional dependencies
-if [ -z $crate ] || [ -z $tag ] || [ -z $target ]; then
- need cut
-fi
-
-if [ -z $tag ]; then
- need rev
-fi
-
-if [ -z $target ]; then
- need grep
- need rustc
-fi
-
-if [ -z $git ]; then
- err 'must specify a git repository using `--git`. Example: `install.sh --git japaric/cross`'
-fi
-
-url="https://github.com/$git"
-say_err "GitHub repository: $url"
-
-if [ -z $crate ]; then
- crate=$(echo $git | cut -d'/' -f2)
-fi
-
-say_err "Crate: $crate"
-
-url="$url/releases"
-
-if [ -z $tag ]; then
- tag=$(curl -s "$url/latest" | cut -d'"' -f2 | rev | cut -d'/' -f1 | rev)
- say_err "Tag: latest ($tag)"
-else
- say_err "Tag: $tag"
-fi
-
-if [ -z $target ]; then
- target=$(rustc -Vv | grep host | cut -d' ' -f2)
-fi
-
-say_err "Target: $target"
-
-if [ -z $dest ]; then
- dest="$HOME/.cargo/bin"
-fi
-
-if [ $no_tag = true ]; then
- crate_tag="$crate"
-elif case $tag in "$crate"*) true ;; *) false ;; esac then
- crate_tag="$tag"
-else
- crate_tag="$crate-$tag"
-fi
-
-say_err "Installing to: $dest"
-url="$url/download/$tag/${crate_tag}-$target.tar.gz"
-
-say_err "Downloading: $url"
-
-td=$(mktemp -d || mktemp -d -t tmp)
-curl -sL $url | tar -C $td -xz
-
-for f in $(find "$td" -type f); do
- case $f in
- *".bash")
- [ $completion_bash ] && install -D $f "$comp_dir_bash/$crate"
- ;;
- *".zsh" | *"_$crate")
- [ $completion_zsh ] && install -D $f "$comp_dir_zsh/_$crate"
- ;;
- *".fish")
- [ $completion_fish ] && install -D $f "$comp_dir_fish/$crate.fish"
- ;;
- *) ;;
- esac
-
- test -x $f || continue
- if [ -e "$dest/$f" ] && [ $force = false ]; then
- err "$(dirname $f) already exists in $dest"
- else
- install -Dm 755 $f $dest
- fi
-done
-
-rm -rf $td
diff --git a/scripts/.local/bin/mega-dl.sh b/scripts/.local/bin/mega-dl.sh
deleted file mode 100755
index b19be68..0000000
--- a/scripts/.local/bin/mega-dl.sh
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/bin/bash
-
-# Source: https://gist.github.com/zanculmarktum/170b94764bd9a3da31078580ccea8d7e
-
-# Copyright 2018, 2019, 2020 Azure Zanculmarktum
-# All rights reserved.
-#
-# Redistribution and use of this script, with or without modification, is
-# permitted provided that the following conditions are met:
-#
-# 1. Redistributions of this script must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
-# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# Dependencies:
-# openssl
-
-# Usage:
-# $ ./megafetch.sh https://mega.nz/#!abcdefgh!1234567890abcdefghijklmnopqrstuvwxyzABCDEFG
-# http://gfs208n103.userstorage.mega.co.nz/dl/-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890A
-# file.name
-# abcefghijklmnopqrstuvwxyz0123456
-# 1234567890abcdef0000000000000000
-# $ wget -O file.name http://gfs208n103.userstorage.mega.co.nz/dl/-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890A
-# $ cat file.name | openssl enc -d -aes-128-ctr -K abcefghijklmnopqrstuvwxyz0123456 -iv 1234567890abcdef0000000000000000 > file.name.new
-# $ mv -f file.name.new file.name
-
-URL=""
-OUTPATH="$PWD"
-USAGE="Usage: ${0##*/} <url>"
-
-if [[ $1 =~ ^https?:\/\/mega(\.co)?\.nz ]]; then
- URL="$1"
-fi
-
-if [[ ! $URL ]]; then
- echo $USAGE >&2
- exit 1
-fi
-
-if [[ ! -z "$2" ]]; then
- OUTPATH="$2"
-fi
-
-if [[ ! -d "$OUTPATH" ]]; then
- echo $USAGE >&2
- exit 1
-fi
-
-CURL="curl -Y 1 -y 10"
-
-missing=false
-for cmd in openssl; do
- if [[ ! $(command -v "$cmd" 2>&1) ]]; then
- missing=true
- echo "${0##*/}: $cmd: command not found" >&2
- fi
-done
-if $missing; then
- exit 1
-fi
-
-if [[ $URL =~ .*/file/[^#]*#[^#]* ]]; then
- id="${URL#*file/}"
- id="${id%%#*}"
- key="${URL##*file/}"
- key="${key##*#}"
-else
- id="${URL#*!}"
- id="${id%%!*}"
- key="${URL##*!}"
-fi
-
-raw_hex=$(echo "${key}=" | tr '\-_' '+/' | tr -d ',' | base64 -d -i 2>/dev/null | od -v -An -t x1 | tr -d '\n ')
-hex=$(
- printf "%016x" \
- $((0x${raw_hex:0:16} ^ 0x${raw_hex:32:16})) \
- $((0x${raw_hex:16:16} ^ 0x${raw_hex:48:16}))
-)
-
-json=$($CURL -s -H 'Content-Type: application/json' -d '[{"a":"g", "g":"1", "p":"'"$id"'"}]' 'https://g.api.mega.co.nz/cs?id=&ak=') || exit 1
-json="${json#"[{"}"
-json="${json%"}]"}"
-file_url="${json##*'"g":'}"
-file_url="${file_url%%,*}"
-file_url="${file_url//'"'/}"
-
-json=$($CURL -s -H 'Content-Type: application/json' -d '[{"a":"g", "p":"'"$id"'"}]' 'https://g.api.mega.co.nz/cs?id=&ak=') || exit 1
-at="${json##*'"at":'}"
-at="${at%%,*}"
-at="${at//'"'/}"
-
-json=$(echo "${at}==" | tr '\-_' '+/' | tr -d ',' | openssl enc -a -A -d -aes-128-cbc -K "$hex" -iv "00000000000000000000000000000000" -nopad | tr -d '\0')
-json="${json#"MEGA{"}"
-json="${json%"}"}"
-file_name="${json##*'"n":'}"
-if [[ $file_name == *,* ]]; then
- file_name="${file_name%%,*}"
-fi
-file_name="${file_name//'"'/}"
-
-outfile="$OUTPATH/$file_name"
-
-$CURL -s "$file_url" | openssl enc -d -aes-128-ctr -K "$hex" -iv "${raw_hex:32:16}0000000000000000" >"$outfile"
-
-echo "$outfile"
-
-# echo "$file_url"
-# echo "$file_name"
-# echo "$hex"
-# echo "${raw_hex:32:16}0000000000000000"
diff --git a/scripts/.local/bin/td.sh b/scripts/.local/bin/td.sh
deleted file mode 100755
index 968c98b..0000000
--- a/scripts/.local/bin/td.sh
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/bin/sh
-TEMP=$(getopt -o hf --long help,force \
- -n 'javawrap' -- "$@")
-
-if [ $? != 0 ]; then
- echo "Terminating..." >&2
- exit 1
-fi
-
-eval set -- "$TEMP"
-
-SCRIPT="$(basename $0)"
-ENV_CACHE="${HOME}/.cache/td/.env"
-
-help() {
- cat <<-EOF
-$SCRIPT
-Toby Vincent <tobyv13@gmail.com>
-
-$SCRIPT is a script for managing and navigating a persistent temp directory. In
-order to function properly, this script must be sourced in the currently shell.
-Consider setting an alias such as
-
- alias td=". $SCRIPT"
-
-USAGE:
- $SCRIPT [OPTIONS] <COMMAND>
- $SCRIPT [OPTIONS]
-
-OPTIONS:
- -h, --help Display this message
- -f, --force Use the --force argument when removing TD
-
-ARGS:
- toggle (default)
- Switch between TD_ORIGIN and TD. This will create TD if it does not
- exist. This is the default if no command is provided.
-
- new | create
- Creates a new temp directory and cds into it it stores the path
- to the temp directory in TD, and the path to the previous directory in
- TD_ORIGIN.
-
- rm | remove
- Removes the directory stored in TD unsets TD and TD_ORIGIN.
-
- ls | list | show
- Shows the current values for TD and TD_ORIGIN
-EOF
-}
-
-echo_err() {
- echo >&2 "$SCRIPT: $@"
-}
-
-show() {
- if [ ! -n "$TD" ]; then
- echo_err "Not set"
- return 1
- fi
- echo "TD=$TD"
- echo "TD_ORIGIN=$TD_ORIGIN"
-}
-
-remove() {
- if [ ! -n "$TD" ]; then
- echo_err "Not set"
- return 1
- fi
-
- rm "$rm_args" "$TD"
-
- echo "removed $TD"
-
- if [ "$PWD" = "$TD" ]; then
- cd "$TD_ORIGIN"
- fi
-
- rm "$ENV_CACHE" -rf
- unset TD
- unset TD_ORIGIN
-}
-
-create() {
- remove 2>/dev/null
-
- td=$(mktemp -d)
-
- export TD="$td"
- update-origin
-
- echo "created $TD"
- cd "$TD"
-}
-
-update-origin() {
- export TD_ORIGIN="$PWD"
- cat >$ENV_CACHE <<-EOF
-TD=$TD
-TD_ORIGIN=$TD_ORIGIN
-EOF
-}
-
-toggle() {
- if [ "$PWD" = "$TD" ]; then
- cd "$TD_ORIGIN"
- elif [ -n "$TD" ]; then
- update-origin
- cd "$TD"
- else
- create
- fi
-}
-
-if [ -f "$ENV_CACHE" ]; then
- export $(cat "$ENV_CACHE" | xargs)
-fi
-
-rm_args="-r"
-while test $# -gt 0; do
- case $1 in
- --help | -h)
- help
- return 0
- ;;
- --force | -f)
- rm_args="-rf"
- shift
- ;;
- --)
- shift
- break
- ;;
- *) break ;;
- esac
-done
-
-case $1 in
-ls | list | show)
- show
- ;;
-rm | remove)
- remove
- ;;
-new | create)
- create
- ;;
-* | toggle)
- toggle
- ;;
-esac