diff options
| author | EuAndreh <eu@euandre.org> | 2022-01-04 15:41:32 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2022-01-04 15:41:32 -0300 |
| commit | 8b9a649ac05469881e17a63112cef69bdc19ed08 (patch) | |
| tree | 8d75b443361d9dbb85ca2a26c54c9d32cc019034 /scripts | |
| parent | .gitignore: Remove /cron/generated/ (diff) | |
| download | dotfiles-8b9a649ac05469881e17a63112cef69bdc19ed08.tar.gz dotfiles-8b9a649ac05469881e17a63112cef69bdc19ed08.tar.xz | |
scripts/: Move executables to src/bin/, and add a proper CLI interface to them
Diffstat (limited to '')
| l--------- | scripts/backup | 1 | ||||
| -rwxr-xr-x | scripts/commit-md | 26 | ||||
| -rwxr-xr-x | scripts/fim | 4 | ||||
| -rwxr-xr-x | scripts/gc-mail.sh | 10 | ||||
| -rwxr-xr-x | scripts/gc-nix.sh | 19 | ||||
| -rwxr-xr-x | scripts/gc.sh | 48 | ||||
| -rwxr-xr-x | scripts/open | 29 | ||||
| -rwxr-xr-x | scripts/yt | 80 | ||||
| l--------- | src/bin/xdg-open (renamed from scripts/xdg-open) | 0 |
9 files changed, 0 insertions, 217 deletions
diff --git a/scripts/backup b/scripts/backup deleted file mode 120000 index 2343098e..00000000 --- a/scripts/backup +++ /dev/null @@ -1 +0,0 @@ -../cron/run-local-backup.sh
\ No newline at end of file diff --git a/scripts/commit-md b/scripts/commit-md deleted file mode 100755 index 91610b6d..00000000 --- a/scripts/commit-md +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -set -eu - -LAST_COMMIT="$(git rev-parse HEAD)" -COMMIT="${1:-$LAST_COMMIT}" -REPOSITORY="$(basename "$PWD")" - -usage() { - cat <<EOF -Usage: - $0 [COMMIT] -EOF -} - -if [ -z "$COMMIT" ]; then - echo "Missing \$COMMIT argument" - usage >&2 - exit 2 -fi - -LINK="$(printf 'https://git.euandreh.xyz/%s/commit/?id=%s' "$REPOSITORY" "$COMMIT")" -MD="$(printf '[`%s`](%s)' "$COMMIT" "$LINK")" - -xdg-open "$LINK" -printf '%s' "$MD" | xclip -sel clip -printf 'Copied %s to the clipboard!\n' "$MD" >&2 diff --git a/scripts/fim b/scripts/fim deleted file mode 100755 index 040dbe99..00000000 --- a/scripts/fim +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -set -eu - -play "$DOTFILES/sh/Positive.ogg" 2> /dev/null diff --git a/scripts/gc-mail.sh b/scripts/gc-mail.sh deleted file mode 100755 index 9a04cddb..00000000 --- a/scripts/gc-mail.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -set -eux - -# shellcheck source=/dev/null -. "$DOTFILES/sh/colors.sh" - -# Source: https://www.reddit.com/r/emacs/comments/6wqfp3/notmuch_delete_mail/ -yellow "Clean up deleted email files" -notmuch search --output=files --exclude=false tag:deleted | xargs -I{} rm "{}" -notmuch new diff --git a/scripts/gc-nix.sh b/scripts/gc-nix.sh deleted file mode 100755 index 7c22c1d9..00000000 --- a/scripts/gc-nix.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -set -eu - -# shellcheck source=/dev/null -. "$DOTFILES/sh/colors.sh" -yellow "Cleaning up the NixOS store\n" - -PROFILES="$(mktemp)" -printf "per-user/root/channels\nper-user/andreh/profile\nper-user/andreh/channels\nsystem\n" > "$PROFILES" - -while IFS='' read -r p; do - sudo nix-env --delete-generations old -p "/nix/var/nix/profiles/$p" -done < "$PROFILES" - -# Current profile, change when installing with =nix-env -iA nixpkgs.bsdgames= -nix-env --delete-generations old - -nix-store --gc -nix-collect-garbage -d diff --git a/scripts/gc.sh b/scripts/gc.sh deleted file mode 100755 index f432c0c5..00000000 --- a/scripts/gc.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -set -eu - -# shellcheck source=/dev/null -. "$DOTFILES/sh/colors.sh" - -disk_space() { - u | awk '{print $5" "$6}' -} - -before=$(disk_space) - -gc-nix.sh - -yellow "Cleaning up Guix store\n" - -guix gc -d - - -yellow "Cleaning up up the Trash and /tmp folders\n" - -sudo rm -rf ~/.local/share/Trash/files/* -# https://askubuntu.com/a/609396 -sudo find /tmp -type f -atime +10 -delete - -if which docker; then - - yellow "Erasing docker images\n" - - echo y | docker system prune -a - docker rmi "$(docker images -a -q)" ||: - docker rm "$(docker ps -a -f status=exited -q)" ||: - - docker stop "$(docker ps -a -q)" ||: - docker rm "$(docker ps -a -q)" ||: - - echo y | docker volume prune - echo y | docker container prune -fi - -gc-mail.sh - -after=$(disk_space) - -green "Done.\n" -green "Disk space before and after:\n" -blue " before: ${before}\n" -blue " after: ${after}\n" diff --git a/scripts/open b/scripts/open deleted file mode 100755 index 23f12fe2..00000000 --- a/scripts/open +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -set -eu - -if [ -z "${1:-}" ]; then - exit -fi - -set -x - -case "$1" in - *.ico|*.jpg|*.jpeg|*.png) - feh "$1" - ;; - https://www.youtube.com/watch*) - vid "$1" - ;; - http*|*.svg|*.html) - "$BROWSER" "$1" - ;; - *.pdf|*.djvu) - nohup zathura "$1" 1>&2 2>/dev/null & - ;; - *.flac|*.ogg|*.mkv) - vid "$1" - ;; - *) - /run/current-system/sw/bin/xdg-open "$1" - ;; -esac diff --git a/scripts/yt b/scripts/yt deleted file mode 100755 index ba7feb20..00000000 --- a/scripts/yt +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -set -eu - -export DEFAULT_PLAYLIST_END=15 -export DEFAULT_INC_STEP=10 -export YT_TEMPLATE="${HOME}/Downloads/yt-dl/%(uploader)s/%(upload_date)s %(title)s.%(ext)s" - -download() { - youtube-dl "$1" \ - --download-archive ~/archive/youtube-dl-seen.conf \ - --prefer-free-formats \ - --playlist-end "$2" \ - --write-description \ - --output "$YT_TEMPLATE" -} - -download_user() { - download "https://www.youtube.com/user/$1" "${2-$DEFAULT_PLAYLIST_END}" -} - -download_channel() { - download "https://www.youtube.com/channel/$1" "${2-$DEFAULT_PLAYLIST_END}" -} - -download_playlist() { - download "https://www.youtube.com/playlist?list=$1" "${2-$DEFAULT_PLAYLIST_END}" -} - -inc_download() { - fn="$1" - id="$2" - step="${3-$DEFAULT_INC_STEP}" - - file="$HOME/.yt-db/$id" - mkdir -p "$HOME/.yt-db" - cat "$file" 2> /dev/null - n_count="$(cat "$file" 2> /dev/null || printf 10)" - n_count_new="$((n_count + step))" - - echo "$n_count_new" > "$file" - - "$fn" "$id" "$n_count" -} - -# Always downloads video, doesn't look at the download-archive - -URL_OR_PATH="${1:-}" -[ -z "${URL_OR_PATH}" ] && { - # shellcheck disable=2016 - echo 'Input "$URL_OR_PATH" is undefined.' > /dev/stderr - exit 2 -} - -if [ -f "${URL_OR_PATH}" ]; then - echo "File '${URL_OR_PATH}' exists, loading URLs from it..." > /dev/stderr - youtube-dl --batch-file "${URL_OR_PATH}" \ - --format best \ - --output "${YT_TEMPLATE}" \ - --write-description \ - 1>&2 - FILES="$(youtube-dl --batch-file "${URL_OR_PATH}" \ - --output "${YT_TEMPLATE}" \ - --format best \ - --get-filename)" -else - echo "File '${URL_OR_PATH}' doesn't exist, treating it as an URL..." > /dev/stderr - youtube-dl "${URL_OR_PATH}" \ - --output "${YT_TEMPLATE}" \ - --format best \ - --write-description \ - 1>&2 - FILES="$(youtube-dl "${URL_OR_PATH}" \ - --output "${YT_TEMPLATE}" \ - --format best \ - --get-filename)" -fi - -for f in $FILES; do - videq "$f" -done diff --git a/scripts/xdg-open b/src/bin/xdg-open index ce4a72b8..ce4a72b8 120000 --- a/scripts/xdg-open +++ b/src/bin/xdg-open |
