Skip to content

Instantly share code, notes, and snippets.

@jiskanulo
Created May 18, 2026 10:01
Show Gist options
  • Select an option

  • Save jiskanulo/ab49d6cef053c6b9109569c282c8efc5 to your computer and use it in GitHub Desktop.

Select an option

Save jiskanulo/ab49d6cef053c6b9109569c282c8efc5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Takumi Guard の registry を pip / pip3 / npm / pnpm / bundle に公式コマンド経由で設定する。
set -euo pipefail
# ----------------------------------------------------------------------
# 実行前の注意書き
# ----------------------------------------------------------------------
read -r -d '' NOTICE <<'EOF' || true
実行前にこのスクリプトの内容は確認しましたか?
内容を理解せず実行しようとしていませんか?
不安な場合は実行前にこのスクリプトについての解説をお手元のAIで確認してください!
EOF
confirm() {
printf '%s\n\n' "$NOTICE"
printf '実行しますか? [y/N]: '
local ans
read -r ans
case "$ans" in
y|Y|yes|YES) return 0 ;;
*) echo "aborted."; exit 1 ;;
esac
}
log() { printf '[takumi-guard:cmd] %s\n' "$*"; }
skip() { printf '[takumi-guard:cmd] skip: %s\n' "$*"; }
setup_pip() {
if command -v pip >/dev/null 2>&1; then
pip config set global.index-url https://pypi.flatt.tech/simple/
log "pip: set global.index-url"
else
skip "pip: command not found"
fi
if command -v pip3 >/dev/null 2>&1; then
pip3 config set global.index-url https://pypi.flatt.tech/simple/
log "pip3: set global.index-url"
else
skip "pip3: command not found"
fi
}
setup_npm() {
if command -v npm >/dev/null 2>&1; then
npm config set registry https://npm.flatt.tech/ --location=global
log "npm: set registry"
else
skip "npm: command not found"
fi
if command -v pnpm >/dev/null 2>&1; then
pnpm config set registry https://npm.flatt.tech
log "pnpm: set registry"
else
skip "pnpm: command not found"
fi
}
setup_bundle() {
if command -v bundle >/dev/null 2>&1; then
bundle config set --global mirror.https://rubygems.org https://rubygems.flatt.tech
log "bundle: set mirror"
else
skip "bundle: command not found"
fi
}
main() {
confirm
setup_pip
setup_npm
setup_bundle
log "done"
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment