Skip to content

Shell snippets

(The snippets on this page are MIT-0. Use them how you want!)

Clean a directory and rebuild a specfile

srpm() {
    find -mindepth 1 -maxdepth 1 -name '*.src.rpm' -delete -print
    spectool -g "$1"
    rpmbuild -bs "$@"
}

Download a video with full metadata

alias ytdlp='yt-dlp --add-metadata --write-sub'

Get the full path of a file

alias rl='readlink -f'

Git aliases

alias gp='git push'
alias gl='git pull'
alias grbS='git rebase -S'

Merge back rawhide to stable Fedoras

The || break makes sure the loop stops if one branch fails.

for b in f39 f38 f37; do; (git switch $b && grbS rawhide && gp && fedpkg build --nowait) || break; done

Create updates for stable Fedoras

for b in f39 f38 f37; do; fedpkg --release $b update --type=enhancement --notes "$(git show -q --format=%s HEAD)" || break; done

Set ZSH history to a high number

You’ll thank me later when you need to find a command.

HISTFILE=~/.zhistory
HISTSIZE=10000
SAVEHIST="${HISTSIZE}"

Guess the id of the next Github PR in a repo

This is useful for repositories that use tools like towncrier or antsibull-changelog or similar tools that require identifying the PR in a changelog entry.

nextpr() {
    echo "$(( "$((for i in pr issue; gh $i list --state all | head -n1 | awk '{print $1}') | sort -h | tail -n1)" + 1 ))"
}

This prevents you from accidentally using pip to modify your global environment.

alias pip='PIP_REQUIRE_VIRTUALENV=true /usr/bin/env pip'
alias pipnv='/usr/bin/env pip'