Add base configuration
- Follow XDG standard: ~/.config and ~/.local folders - Set environment variables and define aliases within ~/.config/shell - Add installation script for easy setup - Add README.md with info on the installation and general notes
This commit is contained in:
commit
74d1e2ab00
10 changed files with 258 additions and 0 deletions
3
.local/bin/README.md
Normal file
3
.local/bin/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# User-local Executables
|
||||
|
||||
This folder contains executable files that are on the `$PATH`.
|
||||
91
.local/bin/install-dotfiles
Executable file
91
.local/bin/install-dotfiles
Executable file
|
|
@ -0,0 +1,91 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Installation script to make the dotfiles available in ~/
|
||||
#
|
||||
# `git` is the only dependency for this script to run (See: https://git-scm.com)
|
||||
#
|
||||
# See: https://code.webartifex.biz/alexander/dotfiles#installation
|
||||
|
||||
|
||||
set -eu
|
||||
|
||||
|
||||
XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" # also set in ~/.config/shell/env
|
||||
|
||||
DOTFILES_DIR="$XDG_DATA_HOME/dotfiles" # also set in ~/.config/shell/env
|
||||
|
||||
# Defaults to the minimal/server version on the "main" branch
|
||||
# => Set DOTFILES_BRANCH=desktop explicitly when installing on a desktop machine
|
||||
DOTFILES_BRANCH="${DOTFILES_BRANCH:-main}"
|
||||
|
||||
DOTFILES_HTTPS="https://code.webartifex.biz/alexander/dotfiles"
|
||||
DOTFILES_SSH="git@git.webartifex.biz:alexander/dotfiles.git"
|
||||
|
||||
BACKUP_DIR="$HOME/.dotfiles-backup-$(date +%Y%m%d-%H%M%S)"
|
||||
|
||||
|
||||
if [ -d "$DOTFILES_DIR" ]; then
|
||||
|
||||
if [ "${FORCE_INSTALL:-}" != "1" ]; then
|
||||
echo ""
|
||||
echo "The dotfiles are already installed at: $DOTFILES_DIR"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " - Set 'export FORCE_INSTALL=1' and run installation again"
|
||||
echo " - Update with 'dotfiles pull' and continue using them"
|
||||
echo ""
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Backing up the existing repository to: $BACKUP_DIR"
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
mv "$DOTFILES_DIR" "$BACKUP_DIR/dotfiles"
|
||||
|
||||
fi
|
||||
|
||||
|
||||
git clone --bare "$DOTFILES_HTTPS" "$DOTFILES_DIR"
|
||||
|
||||
|
||||
_git() {
|
||||
git --git-dir="$DOTFILES_DIR" --work-tree="$HOME" "$@"
|
||||
}
|
||||
|
||||
|
||||
if ! _git show-ref --verify --quiet "refs/heads/$DOTFILES_BRANCH"; then
|
||||
echo ""
|
||||
echo "Branch '$DOTFILES_BRANCH' does not exist in the repository"
|
||||
echo ""
|
||||
echo "Available branches:"
|
||||
_git branch --format=' %(refname:short)'
|
||||
echo ""
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Do not checkout project documentation intended for web GUIs
|
||||
_git config core.sparseCheckout true
|
||||
{
|
||||
echo "/*"
|
||||
echo "!LICENSE.txt"
|
||||
echo "!README.md"
|
||||
} > "$DOTFILES_DIR/info/sparse-checkout"
|
||||
|
||||
# Put the dotfiles in the user's $HOME folder
|
||||
_git checkout --force "$DOTFILES_BRANCH"
|
||||
|
||||
# Do not show files not tracked in the dotfiles repository because there are simply too many
|
||||
_git config --local status.showUntrackedFiles no
|
||||
|
||||
# Prefer `ssh` for syncing between the machines
|
||||
_git remote set-url origin "$DOTFILES_SSH"
|
||||
|
||||
|
||||
echo ""
|
||||
echo "The dotfiles were installed successfully (branch: $DOTFILES_BRANCH)"
|
||||
echo ""
|
||||
echo "Reload your shell to start using them:"
|
||||
echo " exec \$SHELL -l"
|
||||
echo ""
|
||||
Loading…
Add table
Add a link
Reference in a new issue