migration

This commit is contained in:
kokopi-dev
2025-10-28 16:23:11 +09:00
commit 2f27c335cf
116 changed files with 8221 additions and 0 deletions

4
scripts/framework-stats.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
BAT_CYCLE=$(cat /sys/class/power_supply/BAT1/cycle_count)
echo -e "Note: 80% retained after 1000 cycles\n Current Cycles: $BAT_CYCLE cycles"

30
scripts/git-token Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
# Simple script to inject token:name into existing git remote URL
# Usage: git-token <n> <token>
[ $# -ne 2 ] && { echo "Usage: git-token <username> <token>"; exit 1; }
NAME="$1"
TOKEN="$2"
REMOTE=$(git remote get-url origin 2>/dev/null) || { echo "No origin remote found"; exit 1; }
# if ssh convert, else normal
if [[ $REMOTE =~ ^git@([^:]+):(.+)$ ]]; then
# SSH format: git@host:path -> https://token:name@host/path
HOST="${BASH_REMATCH[1]}"
PATH="${BASH_REMATCH[2]}"
NEW_URL="https://${NAME}:${TOKEN}@${HOST}/${PATH}"
elif [[ $REMOTE =~ ^https://(.+)$ ]]; then
# HTTPS format: https://rest -> https://token:name@rest
NEW_URL="https://${NAME}:${TOKEN}@${BASH_REMATCH[1]}"
else
echo "Unsupported remote format: $REMOTE"
exit 1
fi
# Set new remote
git remote set-url origin "$NEW_URL"
echo "Remote updated: $NEW_URL"

41
scripts/init.sh Executable file
View File

@@ -0,0 +1,41 @@
#!/bin/bash
# init needs to be ran in this specific script's folder
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
imp() {
local path="$1"
if [ -f "$path" ]; then
set -a
source $path
set +a
fi
}
imp "utils/import_print"
current_script=$(basename "$0")
if [ ! -d "$HOME/.local/bin" ]; then
print_status "INFO" "~/.local/bin directory does not exist"
mkdir -p ~/.local/bin
print_status "INFO" "Created ~/.local/bin ..."
fi
changed_count=0
unchanged_count=0
for file in *; do
[ "$file" = "$current_script" ] && continue
[ ! -f "$file" ] && continue
target_path="$HOME/.local/bin/$file"
if [ -e "$target_path" ]; then
# dont change
((unchanged_count++))
else
ln -s "${SCRIPT_DIR}/$file" "$target_path"
((changed_count++))
print_status "OK" "Added $target_path"
fi
done
print_status "OK" "Ignored: $unchanged_count, Added: $changed_count scripts"

View File

@@ -0,0 +1,19 @@
#!/bin/bash
# print colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
print_status() {
local status=$1
local message=$2
case $status in
"OK") echo -e "${GREEN}[OK]${NC} $message" >&2 ;;
"WARN") echo -e "${YELLOW}[WARN]${NC} $message" >&2 ;;
"ERROR") echo -e "${RED}[ERROR]${NC} $message" >&2 ;;
"INFO") echo -e "${BLUE}[INFO]${NC} $message" >&2 ;;
esac
}

3
scripts/vim-undodir-clean.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
# clean undo files beyond 30 days
find ~/.vim/undodir -type f -mtime +30 -delete