This commit finalizes the multi-host deployment framework, introducing the laptop profile alongside the desktop. It integrates essential hardware services, declaratively binds the Hyprland compositor, and thoroughly documents the repository architecture. - Initialize `hosts/laptop` profile configured for the Niri compositor, utilizing `lib.mkForce` to override default `greetd` logic. - Declare `hyprland.conf` directly via Home Manager (`home.file`) to ensure reproducible compositor settings (blur, gaps, bindings). - Enable Bluetooth daemon (`hardware.bluetooth`) and printing services (`cups-pk-helper`) system-wide. - Configure default system typography with `inter` and `fira-code` via `fonts.fontconfig`. - Enhance `tuigreet` login screen with session memory, password asterisks, and a custom declarative greeting. - Add comprehensive inline documentation to all Nix modules and shell scripts, alongside a complete project `README.md`. - Update the Home Manager declarations in flake.nix to include home-manager.backupFileExtension = "backup" Rationale: Hardcoding the Hyprland configuration and core hardware services ensures the desktop is fully immutable. Branching the host profiles allows the laptop to share 100% of the user-space configurations (terminal, editor, shell aliases) while cleanly swapping the graphical compositor stack to Niri.
87 lines
2.8 KiB
Bash
87 lines
2.8 KiB
Bash
# 🌟 Custom Git Automation & Helper Utilities
|
|
# Sourced in .bashrc to streamline gitignore modifications, commit-push workflows, and new repo setups.
|
|
|
|
# 1. gitignore: Quickly appends patterns to the repository's root .gitignore file
|
|
# then automatically commits and pushes the change.
|
|
gitignore() {
|
|
if [ $# -eq 0 ]; then
|
|
echo "Usage: gitignore <pattern> [pattern...]"
|
|
return 1
|
|
fi
|
|
|
|
# Find the top-level repository directory path
|
|
local GIT_ROOT=$(git rev-parse --show-toplevel 2> /dev/null)
|
|
if [ -z "$GIT_ROOT" ]; then
|
|
echo "Error: Not a Git repository."
|
|
return 1
|
|
fi
|
|
|
|
local GIT_IGNORE_FILE="$GIT_ROOT/.gitignore"
|
|
|
|
if [ ! -f "$GIT_IGNORE_FILE" ]; then
|
|
touch "$GIT_IGNORE_FILE"
|
|
fi
|
|
|
|
# Ensure the gitignore file ends with a trailing newline if it has content
|
|
if [ -s "$GIT_IGNORE_FILE" ] && [ "$(tail -c1 "$GIT_IGNORE_FILE" | wc -l)" -eq 0 ]; then
|
|
echo "" >> "$GIT_IGNORE_FILE"
|
|
fi
|
|
|
|
local added_count=0
|
|
local commit_msg_list=""
|
|
|
|
for pattern in "$@"; do
|
|
# Check if the pattern is already present in the .gitignore file
|
|
if rg -Fxq "$pattern" "$GIT_IGNORE_FILE"; then
|
|
echo "Skipping '$pattern' (already in .gitignore)"
|
|
else
|
|
echo "$pattern" >> "$GIT_IGNORE_FILE"
|
|
echo "Added '$pattern'"
|
|
((added_count++))
|
|
commit_msg_list+="${pattern}, "
|
|
fi
|
|
done
|
|
|
|
# If any patterns were added, commit and push them automatically
|
|
if [ $added_count -gt 0 ]; then
|
|
commit_msg_list="${commit_msg_list%, }"
|
|
echo "Committing and pushing changes..."
|
|
git add "$GIT_IGNORE_FILE"
|
|
git commit -m "Add to .gitignore: $commit_msg_list"
|
|
git push
|
|
else
|
|
echo "No new patterns were added."
|
|
fi
|
|
}
|
|
|
|
# 2. gacp: Git Add, Commit, and Push shorthand
|
|
# Performs a global staging, commits with the specified message, and pushes to origin on the active branch.
|
|
gacp() {
|
|
if [ -z "$1" ]; then
|
|
echo "Usage: gacp <commit-message>"
|
|
return 1
|
|
fi
|
|
git add -A
|
|
git commit -m "$1"
|
|
local branch_name=$(git branch --show-current)
|
|
git push origin "${branch_name}"
|
|
echo "Pushed to origin/${branch_name}"
|
|
}
|
|
|
|
# 3. new-repo: Initializes a new directory, git repository, and pushes it to GitHub via 'gh' CLI.
|
|
new-repo() {
|
|
if [ -z "$1" ]; then
|
|
echo "Usage: new-repo <repository-name>"
|
|
return 1
|
|
fi
|
|
local repo_name="$1"
|
|
mkdir -p "$repo_name"
|
|
cd "$repo_name" || return 1
|
|
git init -b main
|
|
echo "# $repo_name" > README.md
|
|
touch .gitignore LICENSE
|
|
git add -A && git commit -m "Initial commit"
|
|
# Call the GitHub CLI tool to create the repository on GitHub
|
|
gh repo create "$repo_name" --public --source=. --remote=origin --push
|
|
}
|