justfiles for automating various tasks on my workstation

Add other justfiles

+64
blogging.just
···
+
# New blog entry
+
[group('blogging')]
+
newblog slug:
+
#!/usr/bin/env bash
+
BLOG_DIR="${HOME}/repos/tildegit.org/hyperreal/hyperreal.coffee"
+
FILENAME_DATE=$(date '+%Y-%m-%d')
+
POST_DATE=$(date '+%Y-%m-%d %H:%M:%S')
+
FILENAME="${FILENAME_DATE}-{{ slug }}.md"
+
cat <<EOF >"${BLOG_DIR}/content/posts/${FILENAME}"
+
+++
+
title = ''
+
date = $POST_DATE
+
tags = []
+
+++
+
+
EOF
+
nvim "${BLOG_DIR}/content/posts/${FILENAME}"
+
+
# New feelslog entry
+
[group('blogging')]
+
newfeels tags:
+
#!/usr/bin/env bash
+
DATE=$(date '+%Y-%m-%d')
+
TAGS="$@"
+
FEELSDIR="${HOME}/nextcloud/sites/feels.hyperreal.coffee"
+
PREV_ENTRY=$(find "$FEELSDIR/src" -name "*.md" -exec basename {} \; | sort | tail -1 | cut -c 18-21)
+
NEXT_ENTRY="00$(echo "$PREV_ENTRY" + "1" | bc)"
+
NEXT_ENTRY_FILENAME="${FEELSDIR}/src/${DATE}-entry-${NEXT_ENTRY}.md"
+
URL="$(echo "$DATE" | tr "-" "/")/entry-${NEXT_ENTRY}/"
+
cat <<EOF >"$NEXT_ENTRY_FILENAME"
+
---
+
title: Entry $NEXT_ENTRY
+
date: $(date '+%Y-%m-%d %H:%M:%S %z')
+
tags: $(echo "${TAGS// /, }")
+
slug: entry-$NEXT_ENTRY
+
---
+
+
EOF
+
nvim "$NEXT_ENTRY_FILENAME"
+
echo "URL: https://feels.hyperreal.coffee/${URL}"
+
+
# Publish feelslog
+
[group('blogging')]
+
publish-feels:
+
#!/usr/bin/env bash
+
set -euo pipefail
+
BSSG_DIR="${HOME}/repos/brew.bsd.cafe/stefano/BSSG"
+
if [ ! -d "$BSSG_DIR" ]; then
+
mkdir -p "${HOME}/repos/brew.bsd.cafe/stefano"
+
git clone https://brew.bsd.cafe/stefano/BSSG.git "$BSSG_DIR"
+
fi
+
FEELS_CONFIG="${HOME}/nextcloud/sites/feels.hyperreal.coffee/config.sh.local"
+
OUTPUT_DIR="${HOME}/nextcloud/sites/feels.hyperreal.coffee/output"
+
SITE_URL="https://feels.hyperreal.coffee"
+
REMOTE_USER="jas"
+
REMOTE_HOST="hyperreal.carp-wyvern.ts.net"
+
REMOTE_PATH="/home/jas/public/feels"
+
cd "$BSSG_DIR"
+
"${BSSG_DIR}/bssg.sh" build --config "$FEELS_CONFIG"
+
rsync -az --delete "$OUTPUT_DIR"/ "${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_PATH}"
+
echo
+
echo "Site deployed successfully"
+
+
# vim: ts=4 sts=4 sw=4 et ft=just
-82
cachyos.just
···
-
# Install pacman packages
-
[group('install')]
-
install-pacman-packages:
-
#!/usr/bin/env bash
-
sudo pacman -Syy
-
sudo pacman -S \
-
7zip \
-
atop \
-
autossh \
-
bat \
-
borg \
-
borgmatic \
-
btop \
-
cmake \
-
cmark \
-
curl \
-
diff-so-fancy \
-
duf \
-
fastfetch \
-
fd \
-
firewalld \
-
flatpak \
-
flatpak-xdg-utils \
-
fzf \
-
git \
-
glow \
-
go \
-
gum \
-
htmlq \
-
hugo \
-
incus \
-
jc \
-
jq \
-
komodo \
-
lynx \
-
neovim \
-
nmap \
-
nodejs \
-
nushell \
-
otf-geist-mono-nerd \
-
papirus-icon-theme \
-
parallel \
-
prometheus-node-exporter \
-
pv \
-
python-pipx \
-
qalculate-qt \
-
rclone \
-
ripgrep \
-
rsync \
-
rustup \
-
shellcheck \
-
shfmt \
-
sl \
-
starship \
-
tailscale \
-
tealdeer \
-
termshark \
-
tidy \
-
ttf-jetbrains-mono-nerd \
-
unzip \
-
virtualbox \
-
virtualbox-guest-iso \
-
virtualbox-host-modules-arch \
-
vlc \
-
w3m \
-
wget \
-
wireshark-cli \
-
wireshark-qt \
-
wl-clipboard \
-
xclip \
-
xfsprogs \
-
yakuake \
-
yay-bin \
-
yazi \
-
zellij \
-
zsh \
-
-
# Install AUR packages
-
[group('install')]
-
install-aur-packages:
-
#!/usr/bin/env bash
-
yay -S todotxt
+106
install.just
···
+
# Upgrade Python tools
+
[group('install')]
+
upgrade-python-tools:
+
#!/usr/bin/env bash
+
pipx list --short | awk '{print $1}' | xargs pipx upgrade
+
+
# Ensure formatters are installed
+
[group('install')]
+
ensure-formatters:
+
#!/usr/bin/env bash
+
cargo install --git https://github.com/nushell/nufmt
+
go install github.com/reteps/dockerfmt@latest
+
go install github.com/google/yamlfmt/cmd/yamlfmt@latest
+
sudo npm install -g markdownlint-cli2
+
pipx install ansible-lint
+
pipx install black
+
pipx install isort
+
pipx install nginxfmt
+
sudo pacman -S shellcheck shfmt jq
+
+
# Install todo.txt
+
[group('install')]
+
install-todotxt:
+
#!/usr/bin/env bash
+
URL=$(curl --silent https://api.github.com/repos/todotxt/todo.txt-cli/releases/latest | jq -r '.assets[] | select(.name| test(".*.tar.gz$")).browser_download_url')
+
FILENAME=$(basename "$URL")
+
DIRNAME=$(basename "$URL" .tar.gz)
+
TEMP_DIR=$(mktemp -d)
+
wget "$URL" -O "${TEMP_DIR}/${FILENAME}"
+
tar -zxvf "${TEMP_DIR}/${FILENAME}" -C "${TEMP_DIR}"
+
sudo cp -fv "${TEMP_DIR}/${DIRNAME}/todo.sh" /usr/local/bin/
+
rm -rf "$TEMP_DIR"
+
echo "todo.sh successfully installed to /usr/local/bin/"
+
+
# Install Go tools
+
[group('install')]
+
install-go-tools:
+
#!/usr/bin/env bash
+
go_tools=(
+
"golang.org/x/tools/gopls@latest"
+
"github.com/fatih/gomodifytags@latest"
+
"github.com/cweill/gotests/...@latest"
+
"github.com/x-motemen/gore/cmd/gore@latest"
+
"golang.org/x/tools/cmd/guru@latest"
+
"github.com/themimitoof/ipg@latest"
+
)
+
for x in "${go_tools[@]}"; do
+
go install "$x"
+
done
+
+
# Install Python tools
+
[group('install')]
+
install-python-tools:
+
#!/usr/bin/env bash
+
pipx install ansible --include-deps --force
+
py_tools=(
+
"black"
+
"bpython"
+
"pyflakes"
+
"isort"
+
"pipenv"
+
"nose"
+
"poetry"
+
"pytest"
+
"uv"
+
"qbt-helper"
+
"get-def"
+
"print-wp-sources"
+
)
+
for x in "${py_tools[@]}"; do
+
pipx install "$x"
+
done
+
bpy_inject_tools=("bs4" "requests" "rich" "qbittorrent-api")
+
for x in "${bpy_inject_tools[@]}"; do
+
pipx inject bpython "$x"
+
done
+
+
# Install Node tools
+
[group('install')]
+
install-node-tools:
+
#!/usr/bin/env bash
+
node_tools=(
+
"@bitwarden/cli"
+
"@catppuccin/inkcat"
+
"prettier"
+
"js-beautify"
+
"stylelint"
+
)
+
for x in "${node_tools[@]}"; do
+
sudo npm install -g "$x"
+
done
+
+
# Install Flatpaks
+
[group('install')]
+
install-flatpaks:
+
#!/usr/bin/env bash
+
flatpak install -y \
+
app.zen_browser.zen \
+
com.bitwarden.desktop \
+
com.calibre_ebook.calibre \
+
com.discordapp.Discord \
+
com.github.iwalton3.jellyfin-media-player \
+
com.nextcloud.desktopclient.nextcloud \
+
fi.skyjake.Lagrange
+
+
# vim: ts=4 sts=4 sw=4 et ft=just
+73
notes.just
···
+
# Create new note category
+
[group('notes')]
+
newnotecat category:
+
#!/usr/bin/env bash
+
NOTES_DIR="${HOME}/nextcloud/notes"
+
CATEGORY={{ category }}
+
mkdir -p "${NOTES_DIR}/${CATEGORY}"
+
+
# List note categories
+
[group('notes')]
+
lsnotecats:
+
#!/usr/bin/env bash
+
NOTES_DIR="${HOME}/nextcloud/notes"
+
echo "# Note categories" | gum format -t markdown
+
/bin/ls "$NOTES_DIR" | xargs -I _ printf "- %s/\n" _ | gum format -t markdown
+
+
# New memory recollection
+
[group('notes')]
+
newmem year:
+
#!/usr/bin/env bash
+
MEM_DIR="${HOME}/nextcloud/notes/memories"
+
YEAR={{ year }}
+
if [ ! -f "${MEM_DIR}/${YEAR}.md" ]; then
+
cat <<EOF >"${MEM_DIR}/${YEAR}.md"
+
$YEAR
+
========================
+
+
+
EOF
+
fi
+
nvim "${MEM_DIR}/${YEAR}.md"
+
+
# View memory entry year with glow
+
[group('notes')]
+
viewmem year:
+
#!/usr/bin/env bash
+
MEM_DIR="${HOME}/nextcloud/notes/memories"
+
YEAR={{ year }}
+
glow -p "${MEM_DIR}/${YEAR}.md"
+
+
# List all memory entry years
+
[group('notes')]
+
lsmems:
+
#!/usr/bin/env bash
+
MEM_DIR="${HOME}/nextcloud/notes/memories"
+
echo "# Memory years" | gum format -t markdown
+
/bin/ls "$MEM_DIR" | xargs -I _ printf "- %s\n" _ | gum format -t markdown
+
+
# New private tech note
+
[group('notes')]
+
newtechnote filename:
+
#!/usr/bin/env bash
+
FILENAME={{ filename }}
+
TECHNOTE_DIR="${HOME}/nextcloud/notes/tech"
+
nvim "${TECHNOTE_DIR}/${FILENAME}.md"
+
+
# View private tech note with glow
+
[group('notes')]
+
viewtechnote filename:
+
#!/usr/bin/env bash
+
FILENAME={{ filename }}
+
TECHNOTE_DIR="${HOME}/nextcloud/notes/tech"
+
glow -p "${TECHNOTE_DIR}/${FILENAME}.md"
+
+
# List all private tech notes
+
[group('notes')]
+
lstechnotes:
+
#!/usr/bin/env bash
+
TECHNOTE_DIR="${HOME}/nextcloud/notes/tech"
+
echo "# Tech notes" | gum format -t markdown
+
/bin/ls "$TECHNOTE_DIR" | xargs -I _ printf "- %s\n" _ | gum format -t markdown
+
+
# vim: ts=4 sts=4 sw=4 et ft=just
-81
server.just
···
-
[private]
-
default:
-
@just --list
-
-
[group('install')]
-
packages:
-
#!/usr/bin/env bash
-
if [ -f /etc/debian_version ]; then
-
sudo apt install -y zsh zsh-syntax-highlighting zsh-autosuggestions starship wget curl jq rsync byobu fzf
-
fi
-
-
if [ "$(uname)" = "FreeBSD" ]; then
-
sudo pkg install neovim zsh zsh-syntax-highlighting zsh-autosuggestions starship wget curl jq rsync byobu fzf
-
fi
-
-
[group('init')]
-
zshrc:
-
rm -fv "${HOME}/.zshrc"
-
wget https://files.hyperreal.coffee/zshrc -O "${HOME}/.zshrc"
-
-
[group('init')]
-
starship:
-
mkdir -p "${HOME}/.config"
-
rm -fv "${HOME}/.config/starship.toml"
-
wget https://opengist.hyperreal.coffee/hyperreal/starship/raw/HEAD/starship.toml -O "${HOME}/.config/starship.toml"
-
-
[group('init')]
-
neovim:
-
#!/usr/bin/env bash
-
set -euo pipefail
-
-
if [ ! "$(uname)" = "FreeBSD" ]; then
-
# Determine cpu arch
-
CPU_ARCH=$(uname -m)
-
-
if [ "$CPU_ARCH" = "x86_64" ]; then
-
NVIM_URL=$(curl --silent https://api.github.com/repos/neovim/neovim/releases/latest | jq -r '.assets[] | select(.name| test("nvim-linux-x86_64.tar.gz")).browser_download_url')
-
fi
-
-
if [ "$CPU_ARCH" = "aarch64" ]; then
-
NVIM_URL=$(curl --silent https://api.github.com/repos/neovim/neovim/releases/latest | jq -r '.assets[] | select(.name| test("nvim-linux-arm64.tar.gz")).browser_download_url')
-
fi
-
-
wget "$NVIM_URL" -O /tmp/$(basename $NVIM_URL)
-
tar xzvf /tmp/$(basename $NVIM_URL) -C /tmp
-
sudo rsync -aAXP /tmp/$(basename -s .tar.gz $NVIM_URL)/ /usr/local
-
find /tmp -maxdepth 1 -name "nvim-linux*" -exec rm -rf {} \;
-
fi
-
-
[group('init')]
-
clone-nvim-config:
-
rm -rf "${HOME}/.config/nvim"
-
rm -rf "${HOME}/.local/share/nvim"
-
rm -rf "${HOME}/.local/state/nvim"
-
mkdir -p "${HOME}/.config"
-
git clone https://tildegit.org/hyperreal/nvim-config.git "${HOME}/.config/nvim"
-
sudo rm -rf /root/.config/nvim
-
sudo rm -rf /root/.local/share/nvim
-
sudo rm -rf /root/.local/state/nvim
-
sudo mkdir -p /root/.config
-
sudo git clone https://tildegit.org/hyperreal/nvim-config.git /root/.config/nvim
-
-
[group('setup')]
-
byobu-tmux:
-
#!/usr/bin/env bash
-
if [ -d "${HOME}/.byobu" ]; then
-
BYO_DIR="${HOME}/.byobu"
-
fi
-
-
if [ -d "${HOME}/.config/byobu" ]; then
-
BYO_DIR="${HOME}/.config/byobu"
-
fi
-
-
cat << EOF > "${BYO_DIR}/.tmux.conf"
-
set -g default-terminal "xterm-256color"
-
set-option -ga terminal-overrides ",xterm-256color:Tc"
-
EOF
-
-
all: packages zshrc starship neovim clone-nvim-config
-
-
# vim: ts=4 sts=4 sw=4 et ft=just
+94
setup.just
···
+
# Setup systemd services
+
[group('setup')]
+
setup-services:
+
#!/usr/bin/env bash
+
services=(
+
"atop.service"
+
"atopacct.service"
+
"firewalld.service"
+
"prometheus-node-exporter.service"
+
"snapper-cleanup.timer"
+
"snapper-timeline.timer"
+
"tailscaled.service"
+
)
+
for svc in "${services[@]}"; do
+
if ! sudo systemctl is-active --quiet "$svc"; then
+
sudo systemctl enable --now "$svc"
+
fi
+
done
+
+
# Setup XDG user dirs
+
[group('setup')]
+
setup-xdg-user-dirs:
+
#!/usr/bin/env bash
+
cat <<EOF | sudo tee /etc/xdg/user-dirs.defaults
+
DESKTOP=desktop
+
DOWNLOAD=downloads
+
TEMPLATES=templates
+
PUBLICSHARE=nextcloud
+
DOCUMENTS=documents
+
MUSIC=
+
PICTURES=pictures
+
VIDEOS=
+
EOF
+
+
rm -fv "${HOME}/.config/user-dirs.dirs"
+
for dir in "Desktop" "Documents" "Downloads" "Music" "Pictures" "Public" "Templates" "Videos"; do
+
rm -rfv "${HOME}/${dir}"
+
done
+
xdg-user-dirs-update
+
+
# Setup borgmatic config
+
[group('setup')]
+
setup-borgmatic-config:
+
#!/usr/bin/env bash
+
sudo mkdir /etc/borgmatic
+
sudo wget https://tildegit.org/hyperreal/borgmatic-configs/raw/branch/main/desktop/config.yaml -O /etc/borgmatic/config.yaml
+
sudo systemd-ask-password -n | sudo systemd-creds encrypt - /etc/credstore.encrypted/borgmatic.pw
+
+
# Setup git repos locally
+
[group('setup')]
+
setup-repos:
+
#!/usr/bin/env bash
+
set -euo pipefail
+
+
if [ ! -f "${HOME}/.ssh/id_ed25519" ]; then
+
echo "SSH key not found. Please ensure your SSH key is available."
+
exit 1
+
fi
+
+
echo "Preparing local git directories..."
+
mkdir -p "${HOME}/repos/tildegit.org/hyperreal"
+
+
echo "Cloning repos from tildegit.org/hyperreal..."
+
hyperreal_repos=(
+
"ansible-homelab"
+
"dotfiles"
+
"hyperreal.coffee"
+
"podman-services"
+
"qbt-helper"
+
)
+
for repo in "${hyperreal_repos[@]}"; do
+
if [ -d "${HOME}/repos/tildegit.org/hyperreal/${repo}" ]; then
+
rm -rf "${HOME}/repos/tildegit.org/hyperreal/${repo}"
+
fi
+
git clone "git@tildegit.org:hyperreal/${repo}.git" "${HOME}/repos/tildegit.org/hyperreal/${repo}"
+
done
+
+
# Setup hyperreal configs
+
[group('setup')]
+
setup-cli:
+
#!/usr/bin/env bash
+
set -euo pipefail
+
+
DOTFILES_DIR="${HOME}/repos/tildegit.org/hyperreal/dotfiles"
+
if [ ! -d "$DOTFILES_DIR" ]; then
+
echo "${DOTFILES_DIR} not found."
+
exit 1
+
fi
+
+
find "${DOTFILES_DIR}/config" -maxdepth 1 -mindepth 1 -exec ln -sf {} "${HOME}/.config" \;
+
find "${DOTFILES_DIR}/todo" -maxdepth 1 -mindepth 1 -exec ln -sf {} "${HOME}" \;
+
find "${DOTFILES_DIR}/zsh" -maxdepth 1 -mindepth 1 -exec ln -sf {} "${HOME}" \;
+
+
# vim: ts=4 sts=4 sw=4 et ft=just
+36
utilities.just
···
+
# Quickly copy the Tailscale install command
+
[group('utilities')]
+
copy-ts-cmd:
+
echo "curl -fsSL https://tailscale.com/install.sh | sh" | xclip -selection clipboard
+
+
# Copy GAME screenshots
+
[group('utilities')]
+
copy-screenshots:
+
#!/usr/bin/env bash
+
GAME=$(ugum choose eso starfield bg3)
+
case "$GAME" in
+
"eso")
+
find "${HOME}/.steam/steam/steamapps/compatdata/306130/pfx/drive_c/users/steamuser/Documents/Elder Scrolls Online/live/Screenshots" \
+
-maxdepth 1 \
+
-mindepth 1 \
+
-exec cp -fv {} "${HOME}/nextcloud/pictures/eso_screenshots" \;
+
;;
+
"starfield")
+
find "${HOME}/.steam/steam/steamapps/compatdata/1716740/pfx/drive_c/users/steamuser/My Documents/My Games/Starfield/Data/Textures/Photos" \
+
-maxdepth 1 \
+
-mindepth 1 \
+
-not -name "*-thumbnail.png" \
+
-exec cp -fv {} "${HOME}/nextcloud/pictures/starfield_screenshots" \;
+
;;
+
"bg3")
+
find "${HOME}/games/gog/baldurs-gate-3/drive_c/users/steamuser/My Documents/Larian Studios/Baldur's Gate 3/Screenshots" \
+
-maxdepth 1 \
+
-mindepth 1 \
+
-exec cp -fv {} "${HOME}/nextcloud/pictures/bg3_screenshots" \;
+
;;
+
*)
+
echo "Unknown game"
+
;;
+
esac
+
+
# vim: ts=4 sts=4 sw=4 et ft=just