profile/git.forgejo.profile

134 lines
5.3 KiB
Plaintext

# ~/.profile: executed by Bourne-compatible login shells
# Forgejo container - git user
# Managed by artale
# Last updated: 2026-07-18
# ── Shell options ────────────────────────────────────────────────
HISTSIZE=5000
HISTFILESIZE=10000
HISTTIMEFORMAT="%F %T "
HISTCONTROL=ignoredups:ignorespace
shopt -s histappend checkwinsize
# ── Editor ───────────────────────────────────────────────────────
EDITOR=vi
VISUAL=vi
export EDITOR VISUAL
# ── Forgejo admin shortcuts ─────────────────────────────────────
alias gitea='forgejo'
alias ga='forgejo admin'
alias ga-user='forgejo admin user list'
alias ga-repo='forgejo admin repo-list'
alias ga-queue='forgejo admin queue'
alias gc='forgejo cert'
alias gd='forgejo dump'
alias gu='forgejo upgrade'
# ── Git aliases ──────────────────────────────────────────────────
alias g='git'
alias gs='git status'
alias gl='git log --oneline --graph -20'
alias gb='git branch'
alias gd='git diff'
alias gco='git checkout'
alias gc='git clone'
alias gp='git push'
alias gpl='git pull'
alias gst='git stash'
alias gta='git tag'
alias gclean='git clean -fd'
# ── Repository navigation ───────────────────────────────────────
alias repos='ls -la ~/repositories/'
alias repo-list='find ~/repositories -maxdepth 2 -name "*.git" | sed "s|.*/repositories/||" | sort'
alias repo-size='du -sh ~/repositories/*/*.git 2>/dev/null | sort -rh | head -20'
alias repo-count='find ~/repositories -name "*.git" -type d | wc -l'
# ── Disk and system (data dir) ───────────────────────────────────
alias df='df -h'
alias du='du -sh'
alias ls='ls --color=auto'
alias ll='ls -alF'
alias la='ls -A'
alias lt='ls -ltr'
alias data-size='du -sh /data/* 2>/dev/null | sort -rh | head -20'
alias actions='ls -la /data/actions_log /data/actions_artifacts 2>/dev/null'
# ── Logs ─────────────────────────────────────────────────────────
alias logs='ls -la /data/log/ 2>/dev/null'
alias log-tail='tail -f /data/log/forgejo.log 2>/dev/null || echo "no log file found"'
# ── SSH ──────────────────────────────────────────────────────────
alias ssh-keys='cat ~/.ssh/authorized_keys 2>/dev/null | head -20 || echo "no authorized_keys"'
alias ssh-keys-count='cat ~/.ssh/authorized_keys 2>/dev/null | wc -l || echo "0"'
# ── Functions ────────────────────────────────────────────────────
# Show repo info by name
repo-info() {
local repo="$1"
if [ -z "$repo" ]; then
echo "Usage: repo-info org/repo"
return 1
fi
local path="$HOME/repositories/$repo.git"
if [ -d "$path" ]; then
echo "Repository: $repo"
echo " Path: $path"
echo " Size: $(du -sh "$path" 2>/dev/null | cut -f1)"
echo " Branches:"
git --git-dir="$path" branch -a 2>/dev/null | head -20
echo " Remotes:"
git --git-dir="$path" remote -v 2>/dev/null
echo " Last commit:"
git --git-dir="$path" log -1 --format="%h %ai %s" 2>/dev/null
else
echo "Repository not found: $repo"
echo "Look in: $HOME/repositories/"
fi
}
# List all repos owned by a specific user/org
repos-by() {
local owner="${1:-}"
if [ -z "$owner" ]; then
repo-list
else
find ~/repositories -maxdepth 2 -name "*.git" -path "*/$owner/*" | sed "s|.*/repositories/||" | sed 's|\.git$||' | sort
fi
}
# Last N repos updated
recent-repos() {
local count="${1:-10}"
echo "Most recently updated repositories (top $count):"
find ~/repositories -name "*.git" -type d -exec sh -c 'echo "$(git --git-dir="$1" log -1 --format="%ai" 2>/dev/null) $1"' _ {} \; 2>/dev/null | sort -r | head -"$count" | sed 's|.*/repositories/||' | sed 's|\.git$||'
}
# Forgejo admin - list all repos
ga-repos() {
forgejo admin repo-list 2>/dev/null | head -50
}
# Forgejo admin - user management
ga-users() {
forgejo admin user list 2>/dev/null
}
# Show the artale-owned repos
artale-repos() {
echo "Artale repositories:"
repos-by artale
}
# ── Banner ───────────────────────────────────────────────────────
echo ""
echo "========================================="
echo " Forgejo $(forgejo --version 2>/dev/null | head -1 || echo "?")"
echo " Data: /data ($(du -sh /data 2>/dev/null | cut -f1))"
echo " Repos: $(find ~/repositories -name '*.git' -type d 2>/dev/null | wc -l)"
echo " Users: $(forgejo admin user list 2>/dev/null | wc -l)"
echo "========================================="
echo ""