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
f0e143242b
10 changed files with 228 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`.
|
||||
74
.local/bin/install-dotfiles
Executable file
74
.local/bin/install-dotfiles
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
#!/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 -e
|
||||
|
||||
|
||||
XDG_DATA_HOME="$HOME/.local/share" # also set in ~/.config/shell/env
|
||||
DOTFILES_DIR="$XDG_DATA_HOME/dotfiles" # also set in ~/.config/shell/env
|
||||
|
||||
|
||||
# Check if the dotfiles were installed previously
|
||||
if [ -d "$DOTFILES_DIR" ] && [ "${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 ""
|
||||
else
|
||||
# Remove an already installed dotfiles repository
|
||||
if [ -d "$DOTFILES_DIR" ]; then
|
||||
rm -rf "$DOTFILES_DIR"
|
||||
fi
|
||||
|
||||
if [ -z "$DOTFILES_BRANCH" ]; then
|
||||
# Auto-detect if we're on a desktop system
|
||||
if [ -n "$DISPLAY" ] || [ -n "$WAYLAND_DISPLAY" ] || [ "$(systemctl --user is-active graphical-session.target 2>/dev/null)" = "active" ]; then
|
||||
export DOTFILES_BRANCH="desktop"
|
||||
else
|
||||
export DOTFILES_BRANCH="main"
|
||||
fi
|
||||
elif [ "$DOTFILES_BRANCH" != "desktop" ] && [ "$DOTFILES_BRANCH" != "main" ]; then
|
||||
echo ""
|
||||
echo "'DOTFILES_BRANCH' may only be one of: 'desktop' or 'main'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$XDG_DATA_HOME"
|
||||
|
||||
git clone --bare https://code.webartifex.biz/alexander/dotfiles "$XDG_DATA_HOME/dotfiles"
|
||||
|
||||
# Do not checkout project documentation intended for web GUIs (e.g., GitHub)
|
||||
git --git-dir="$DOTFILES_DIR" --work-tree="$HOME" config core.sparseCheckout true
|
||||
echo "/*" > "$DOTFILES_DIR/info/sparse-checkout"
|
||||
echo "!LICENSE.txt" >> "$DOTFILES_DIR/info/sparse-checkout"
|
||||
echo "!README.md" >> "$DOTFILES_DIR/info/sparse-checkout"
|
||||
|
||||
# Put the dotfiles in the user's `$HOME` folder
|
||||
git --git-dir="$DOTFILES_DIR" --work-tree="$HOME" checkout --force "$DOTFILES_BRANCH"
|
||||
|
||||
# Do not show files not tracked in the dotfiles repository because there are simply too many
|
||||
git --git-dir="$DOTFILES_DIR" --work-tree="$HOME" config --local status.showUntrackedFiles no
|
||||
|
||||
# The author of this file prefers to use SSH to sync his machines with the origin
|
||||
git --git-dir="$DOTFILES_DIR" --work-tree="$HOME" remote set-url origin git@git.webartifex.biz:alexander/dotfiles.git
|
||||
|
||||
echo ""
|
||||
echo "The dotfiles were installed successfully"
|
||||
|
||||
# Mimic starting a new shell to get new dotfiles right away
|
||||
if [ -n "$ZSH_VERSION" ]; then
|
||||
. "$HOME/.zshrc"
|
||||
else
|
||||
. "$HOME/.profile"
|
||||
fi
|
||||
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue