#!/usr/bin/env bash # Usage: # bash <(curl -fsSL ) install mode # wget -qO- | bash install mode # source setup.sh load into current shell (skips install) set -e SETUP_FILE="$HOME/.supraa_setup" SOURCE_LINE='[ -f ~/.supraa_setup ] && source ~/.supraa_setup' _write_setup_file() { cat > "$SETUP_FILE" << 'EOF' # ------------------------------------------------------------------ # ~/.supraa_setup — sourced by .zshrc / .bashrc # ------------------------------------------------------------------ # git function log() { git log -"${1:-10}" --oneline; } function push() { git push; } function pushf() { git push --force; } function pull() { git pull; } function pullr() { git pull --rebase; } function sync() { git pull --rebase && git push; } function gadd() { git add "$@"; } function gdiff() { git diff "$@"; } function comm() { git commit -m "$@"; } function ck() { git checkout "$@"; } function ckf() { git checkout --force "$@"; } function ckb() { git checkout -b "$@"; } function bd() { git branch -D "$1"; } function conflict() { git diff --name-only --diff-filter=U; } function glog() { git log --oneline --graph --decorate -"${1:-20}"; } alias show='git show' alias status='git status' alias gdiff='git diff' alias k='kubectl' # shell function reload() { if [ -n "$ZSH_VERSION" ]; then source ~/.zshrc else source ~/.bashrc fi } function clip() { if command -v xclip &>/dev/null; then cat "$1" | xclip -selection clipboard elif command -v xsel &>/dev/null; then cat "$1" | xsel --clipboard --input elif command -v pbcopy &>/dev/null; then cat "$1" | pbcopy else echo "clip: install xclip or xsel" >&2 fi } alias cls='clear' alias rp='realpath' alias chat='claude' alias chatr='claude --resume' alias settings='${EDITOR:-vim} ~/.zshrc' alias aliases='${EDITOR:-vim} ~/.supraa_setup' alias ls='ls -hal --color=auto' alias py='python3' alias py3='python3' alias python='python3' EOF } _hook_rc() { local rc="$1" if [ -f "$rc" ]; then if grep -q "supraa_setup" "$rc" 2>/dev/null; then echo " already in $rc" else printf '\n%s\n' "$SOURCE_LINE" >> "$rc" echo " hooked into $rc" fi fi } # ---- main -------------------------------------------------------- # If being sourced directly, just load and return if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then # shellcheck source=/dev/null [ -f "$SETUP_FILE" ] && source "$SETUP_FILE" return 0 fi # Install mode echo "Installing ~/.supraa_setup ..." _write_setup_file echo " written $SETUP_FILE" echo "Hooking into rc files ..." _hook_rc "$HOME/.zshrc" _hook_rc "$HOME/.bashrc" echo "" echo "Done. Open a new shell or run: source ~/.supraa_setup"