aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorEugene Triguba <hello@eugenetriguba.com>2025-12-20 10:53:14 -0500
committerEugene Triguba <hello@eugenetriguba.com>2025-12-20 10:54:02 -0500
commit7b6dbb921650e2a52929f025b67be57609fda6d4 (patch)
tree895416312698cfe4ac61d4eed0f071d7743c0214 /bin
parentRemove openbsd conditional in zsh (diff)
downloaddotfiles-7b6dbb921650e2a52929f025b67be57609fda6d4.zip
Rework dotfiles to *only* contain dotfiles
Diffstat (limited to 'bin')
-rwxr-xr-xbin/.local/bin/django-test52
-rwxr-xr-xbin/.local/bin/get-password36
-rwxr-xr-xbin/.local/bin/gh-clone-all102
-rwxr-xr-xbin/.local/bin/migrate-to-sourcehut76
-rwxr-xr-xbin/.local/bin/optimize-image83
-rwxr-xr-xbin/.local/bin/sct-daemon18
-rwxr-xr-xbin/.local/bin/start-tmux12
-rwxr-xr-xbin/.local/bin/tree-sitterbin12489088 -> 0 bytes
8 files changed, 0 insertions, 379 deletions
diff --git a/bin/.local/bin/django-test b/bin/.local/bin/django-test
deleted file mode 100755
index f5081cf..0000000
--- a/bin/.local/bin/django-test
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/env python3
-import ast
-import subprocess
-import sys
-from pathlib import Path
-from typing import override
-
-if len(sys.argv) < 2:
- raise SystemExit("usage: django-test [--list] <func_name>")
-
-list_only = sys.argv[1] == "--list"
-func_name = sys.argv[2] if list_only else sys.argv[1]
-
-repo_root = Path(subprocess.check_output(["git", "rev-parse", "--show-toplevel"], text=True).strip())
-files = subprocess.check_output(["git", "ls-files", "*.py"], text=True, cwd=repo_root).splitlines()
-hits: list[str] = []
-
-for rel_path in files:
- path = repo_root / rel_path
- s = path.read_text(encoding="utf-8")
-
- if func_name not in s:
- continue
- t = ast.parse(s, filename=str(rel_path))
- mod = rel_path[:-3].replace("/", ".").replace("\\", ".")
-
- class V(ast.NodeVisitor):
- cls: str | None = None
-
- @override
- def visit_ClassDef(self, node: ast.ClassDef) -> None:
- old = self.cls
- self.cls = node.name
- self.generic_visit(node)
- self.cls = old
-
- @override
- def visit_FunctionDef(self, node: ast.FunctionDef) -> None:
- if node.name == func_name:
- hits.append(f"{sys.executable} manage.py test {mod}.{self.cls+'.' if self.cls else ''}{func_name}")
- self.generic_visit(node)
-
- V().visit(t)
-
-hits = sorted(set(hits))
-
-if list_only or len(hits) != 1:
- [print(h) for h in hits]
-else:
- cmd = hits[0]
- print(cmd)
- _ = subprocess.run(cmd, shell=True, check=True, cwd=repo_root)
diff --git a/bin/.local/bin/get-password b/bin/.local/bin/get-password
deleted file mode 100755
index 3b83bb7..0000000
--- a/bin/.local/bin/get-password
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-set -e
-
-VAULT="Private"
-CREDENTIAL=""
-
-main() {
- parse_args "$@"
- op read "op://$VAULT/$CREDENTIAL/password"
-}
-
-parse_args() {
- while [ $# -gt 0 ]; do
- case "$1" in
- --vault)
- VAULT="$2"
- shift 2
- ;;
- --credential)
- CREDENTIAL="$2"
- shift 2
- ;;
- *)
- echo "Usage: $0 [--vault <name>] --credential <name>"
- exit 1
- ;;
- esac
- done
-
- if [ -z "$CREDENTIAL" ]; then
- echo "Invalid or empty CREDENTIAL" >&2
- exit 1
- fi
-}
-
-main "$@"
diff --git a/bin/.local/bin/gh-clone-all b/bin/.local/bin/gh-clone-all
deleted file mode 100755
index 77de93a..0000000
--- a/bin/.local/bin/gh-clone-all
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/usr/bin/env bash
-# Clone all repositories from a GitHub user or organization using the gh CLI.
-#
-# Usage:
-# gh-clone-all [--exclude-archived] [--exclude-forks] [--pull] <github-entity> [target-directory]
-#
-# Args:
-# --exclude-archived: If set, skip archived repos (default: include all)
-# --exclude-forks: If set, skip forked repos
-# --pull: If set, pull latest changes in existing repos
-# --limit: The maximum number of repos to clone (default: 10000)
-# <github-entity>: The GitHub username or org (e.g. eugenetriguba)
-# [target-directory]: Optional directory to clone repos into
-set -euo pipefail
-
-EXCLUDE_ARCHIVED=0
-EXCLUDE_FORKS=0
-PULL_EXISTING=0
-ENTITY=""
-TARGET_DIR="."
-LIMIT=10000
-
-main() {
- parse_args "$@"
- clone_all_repos
-}
-
-parse_args() {
- while [[ $# -gt 0 ]]; do
- case "$1" in
- --exclude-archived)
- EXCLUDE_ARCHIVED=1
- shift
- ;;
- --exclude-forks)
- EXCLUDE_FORKS=1
- shift
- ;;
- --pull)
- PULL_EXISTING=1
- shift
- ;;
- --limit)
- LIMIT="$2"
- shift 2
- ;;
- -*)
- usage
- ;;
- *)
- if [[ -z "$ENTITY" ]]; then
- ENTITY="$1"
- elif [[ "$TARGET_DIR" == "." ]]; then
- TARGET_DIR="$1"
- else
- usage
- fi
- shift
- ;;
- esac
- done
- if [[ -z "$ENTITY" ]]; then
- usage
- fi
- mkdir -p "$TARGET_DIR"
-}
-
-usage() {
- echo "Usage: $0 [--exclude-archived] [--exclude-forks] [--pull] [--limit] <github-entity> [target-directory]"
- exit 1
-}
-
-clone_all_repos() {
- gh repo list "$ENTITY" --limit "$LIMIT" --json name,sshUrl,archivedAt,isFork |
- jq -c '.[]' | while read -r repo; do
- NAME=$(echo "$repo" | jq -r '.name')
- CLONE_URL=$(echo "$repo" | jq -r '.sshUrl')
- ARCHIVED_AT=$(echo "$repo" | jq -r '.archivedAt')
- IS_FORK=$(echo "$repo" | jq -r '.isFork')
- DEST="$TARGET_DIR/$NAME"
- if [[ "$EXCLUDE_ARCHIVED" -eq 1 && "$ARCHIVED_AT" != "null" ]]; then
- continue
- fi
- if [[ "$EXCLUDE_FORKS" -eq 1 && "$IS_FORK" == "true" ]]; then
- continue
- fi
- if [[ -d "$DEST" ]]; then
- echo "Repo $NAME already exists."
- if [[ "$PULL_EXISTING" -eq 1 ]]; then
- echo "Pulling latest changes in $DEST"
- git -C "$DEST" pull --ff-only || echo "Warning: git pull failed in $DEST, continuing..."
- else
- echo "Skipping $NAME (already exists)"
- fi
- continue
- fi
- echo "Cloning $CLONE_URL into $DEST"
- git clone "$CLONE_URL" "$DEST"
- done
-}
-
-main "$@"
diff --git a/bin/.local/bin/migrate-to-sourcehut b/bin/.local/bin/migrate-to-sourcehut
deleted file mode 100755
index d7e471a..0000000
--- a/bin/.local/bin/migrate-to-sourcehut
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/bin/bash
-set -euo pipefail
-set -x
-
-REPOS_DIR="$HOME/src/"
-SOURCEHUT_USER="eugenetriguba"
-
-main() {
- parse_args "$@"
-
- cd "$REPOS_DIR"
- for repo in */; do
- if [ -d "$repo/.git" ]; then
- echo "Processing $repo..."
- cd "$repo"
-
- if ! git remote | grep -q "^origin$"; then
- echo "No origin remote found for $repo, skipping..."
- cd ..
- continue
- fi
-
- if ! git remote get-url origin | grep -q "git.sr.ht"; then
- echo "Migrating $repo to SourceHut..."
-
- local repo_name
- repo_name=$(git remote get-url origin | cut -d '/' -f 2 | cut -d '.' -f 1)
- git remote remove origin
- git remote add origin "git@git.sr.ht:~${SOURCEHUT_USER}/${repo_name}"
-
- local current_branch
- current_branch=$(git branch --show-current)
- if [ "$current_branch" = "master" ]; then
- echo "Renaming master branch to main..."
- git branch -m master main
- fi
-
- git push --push-option visiblity="private" -u origin main
- git push origin main --tags
- fi
-
- cd ..
- fi
- done
-}
-
-parse_args() {
- while [[ $# -gt 0 ]]; do
- case "$1" in
- --repos-dir)
- REPOS_DIR="$2"
- shift 2
- ;;
- --sourcehut-user)
- SOURCEHUT_USER="$2"
- shift 2
- ;;
- *)
- echo "Usage: $0 [--repos-dir <path>] [--sourcehut-user <username>]"
- exit 1
- ;;
- esac
-
- if [[ -z "$REPOS_DIR" || ! -d "$REPOS_DIR" ]]; then
- echo "Invalid or empty REPOS_DIR: $REPOS_DIR"
- exit 1
- fi
-
- if [[ -z "$SOURCEHUT_USER" ]]; then
- echo "SOURCEHUT_USER must be specified."
- exit 1
- fi
- done
-}
-
-main "$@"
diff --git a/bin/.local/bin/optimize-image b/bin/.local/bin/optimize-image
deleted file mode 100755
index 075684b..0000000
--- a/bin/.local/bin/optimize-image
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/bin/sh
-set -e
-
-quality=85
-source_img_path=""
-result_img_path=""
-
-main() {
- parse_args "$@"
-
- original_size=$(get_file_size "$source_img_path")
- echo "Optimizing: $source_img_path -> $result_img_path (quality: $quality%)"
- magick "$source_img_path" -strip -quality "${quality}%" "$result_img_path"
- new_size=$(get_file_size "$result_img_path")
- echo "File size: $original_size -> $new_size"
-}
-
-parse_args() {
- while [ $# -gt 0 ]; do
- case $1 in
- --quality)
- if [ -n "$2" ] && [ "$2" -ge 1 ] && [ "$2" -le 100 ] 2>/dev/null; then
- quality="$2"
- shift 2
- else
- echo "Error: --quality requires a number between 1 and 100"
- exit 1
- fi
- ;;
- -h | --help)
- print_usage
- exit 0
- ;;
- -*)
- echo "Error: Unknown option $1"
- print_usage
- exit 1
- ;;
- *)
- if [ -z "$source_img_path" ]; then
- source_img_path="$1"
- else
- echo "Error: Too many arguments"
- print_usage
- exit 1
- fi
- shift
- ;;
- esac
- done
-
- if [ -z "$source_img_path" ]; then
- echo "Error: source image path is required"
- print_usage
- exit 1
- fi
-
- if [ ! -f "$source_img_path" ]; then
- echo "Error: Source file '$source_img_path' does not exist"
- exit 1
- fi
-
- result_img_path="${source_img_path%.*}.webp"
-}
-
-print_usage() {
- echo "Usage: $0 [OPTIONS] <source-img-path>"
- echo ""
- echo "Options:"
- echo " --quality <value> Set quality (1-100, default: 85)"
- echo " -h, --help Show this help message"
- echo ""
- echo "Examples:"
- echo " $0 input.jpg"
- echo " $0 --quality 90 input.jpg"
- echo " $0 --quality 80 input.png"
-}
-
-get_file_size() {
- du -h "$1" | awk '{ print $1 }'
-}
-
-main "$@"
diff --git a/bin/.local/bin/sct-daemon b/bin/.local/bin/sct-daemon
deleted file mode 100755
index b16a67e..0000000
--- a/bin/.local/bin/sct-daemon
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-set -e
-
-while true; do
- hour=$(date +%H)
-
- if [ "$hour" -ge 6 ] && [ "$hour" -lt 18 ]; then
- sct 6500 # day
- elif [ "$hour" -ge 18 ] && [ "$hour" -lt 20 ]; then
- sct 4500 # evening
- elif [ "$hour" -ge 20 ] && [ "$hour" -lt 22 ]; then
- sct 3500 # night
- else
- sct 3000 # late night/early morning
- fi
-
- sleep 600 # check every 10 minutes
-done
diff --git a/bin/.local/bin/start-tmux b/bin/.local/bin/start-tmux
deleted file mode 100755
index fa0e110..0000000
--- a/bin/.local/bin/start-tmux
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-
-readonly SESSION_NAME="$USER"
-
-main() {
- if ! tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
- tmux new-session -A -s "$SESSION_NAME" -d
- fi
- exec tmux attach-session -t "$SESSION_NAME"
-}
-
-main
diff --git a/bin/.local/bin/tree-sitter b/bin/.local/bin/tree-sitter
deleted file mode 100755
index 05ed7f3..0000000
--- a/bin/.local/bin/tree-sitter
+++ /dev/null
Binary files differ