Compare commits

..

No commits in common. "b3e943ea9152776a23db9914ebf23e52e96d8cc2" and "0af21de2c3a41c70b9a84e9ac34921441f7130bf" have entirely different histories.

3 changed files with 19 additions and 477 deletions

View File

@ -1,60 +1,25 @@
# Dotfiles
A collection of configuration files for various tools and applications I use, with an installation script to easily set them up on new systems.
## Installation
### Clone the repository
```bash
# Some Notes
__ To be worked into a setup script at some point __
## Clone repo
```
git clone git@github.com:sebaschi/dotfiles.git ~/.dotfiles
```
{
### Install configurations
The `dot-install` script can be used to install specific configurations or all of them at once:
```bash
# Install everything
~/.dotfiles/dot-install all
# Install specific configurations
~/.dotfiles/dot-install git nvim tmux
# Install only bash aliases
~/.dotfiles/dot-install bash:aliases
## Symlink files to correct locations
```
Run `~/.dotfiles/dot-install` without arguments to see all available options.
## Testing
A test script is included to verify the installation script works correctly:
```bash
~/.dotfiles/test-dot-install
ln -s ~/.dotfiles/git/gitconfig ~/.gitconfig
```
```
ln -s ~/.dotfiles/vim/vimrc ~/.vimrc
```
```
ln -s ~/.dotfiles/bash/bashrc ~/.bashrc
```
## Apps/Tools I use
* 'exa' as replacement for 'ls'
* starship.io
* 'neofetch' CLI for system (OS mostly) info
* 'ncdu" CLI disk use info
* 'htop' process/cpu info. replacement for 'top'
* neovim with lazy.nvim
This runs the installation in an isolated environment to ensure all symlinks are correctly created.
Nothing fancy, just creates mock home in `/tmp` and changes some envars used by the install script.
The "Testing" amounts to check symlinks exist. This is mostly usefull once extended to detect config packages (just the directories containing an a config), to remind me to add a function for it in `dot-install`.
## Included Configurations
* **Shells**: Bash, Fish, Zsh
* **Terminal**: Tmux, Zellij, Ghostty
* **Editors**: Vim, Neovim (with lazy.nvim)
* **Tools**: Git, Starship prompt, Borg backup
* **Utilities**: Rsync filters
## Tools Tools
* `eza` - Modern replacement for `ls`
* `starship.io` - Cross-shell prompt
* `neofetch` - System information tool
* `ncdu` - Disk usage analyzer
* `btop` - Interactive process viewer (replacement for `top`)
* `neovim` - Enhanced vim editor
> [!note]
> TODO: add more tools!

View File

@ -1,278 +0,0 @@
#!/bin/sh
# dot-install: Create symlinks for dotfiles configurations
set -e
DOTFILES_DIR="$(cd "$(dirname "$0")" && pwd)"
CONFIG_DIR="${HOME}/.config"
# Print usage info
usage() {
echo "Usage: dot-install [PACKAGE...] [all]"
echo
echo "Available packages:"
echo " bash - Bash configuration files (all)"
echo " bash:aliases - Bash aliases only"
echo " bash:completion - Bash completion only"
echo " bash:env - Bash environment only"
echo " bash:functions - Bash functions only"
echo " bash:fedora - Fedora specific bash aliases"
echo " borg - Borg backup profiles"
echo " fish - Fish shell configuration"
echo " ghostty - Ghostty terminal configuration"
echo " git - Git configuration"
echo " nvim - Neovim configuration"
echo " rsync - Rsync filter rules"
echo " starship - Starship prompt configuration"
echo " tmux - Tmux configuration"
echo " vim - Vim configuration"
echo " zellij - Zellij terminal multiplexer configuration"
echo " zsh - Zsh configuration"
echo " all - Install all packages"
echo
echo "Example: dot-install bash:aliases git nvim"
exit 1
}
# Create parent directories if they don't exist
ensure_dir() {
if [ ! -d "$1" ]; then
mkdir -p "$1"
echo "Created directory: $1"
fi
}
# Create a symlink and handle existing files
link_file() {
local src="$1"
local dest="$2"
# Check if destination already exists
if [ -e "$dest" ]; then
if [ -L "$dest" ]; then
# If it's already a symlink, check if it points to our file
if [ "$(readlink "$dest")" = "$src" ]; then
echo "Link already exists: $dest -> $src"
return 0
else
echo "Removing existing link: $dest"
rm "$dest"
fi
else
# If it's a regular file or directory
echo "Backing up existing file: $dest -> ${dest}.bak"
mv "$dest" "${dest}.bak"
fi
fi
# Create the symlink
ln -s "$src" "$dest"
echo "Created link: $dest -> $src"
}
# Add source command to bashrc if needed
add_source_to_bashrc() {
local file="$1"
local config_path="$CONFIG_DIR/bash/$file"
if [ -f "$HOME/.bashrc" ]; then
if ! grep -q "source \$HOME/.config/bash/$file" "$HOME/.bashrc"; then
echo "Adding source command for $file to .bashrc"
echo "[ -f \$HOME/.config/bash/$file ] && source \$HOME/.config/bash/$file" >> "$HOME/.bashrc"
fi
else
echo "Warning: $HOME/.bashrc does not exist. You'll need to manually source $file."
fi
}
# Install bash aliases
install_bash_aliases() {
echo "Installing bash aliases..."
ensure_dir "$CONFIG_DIR/bash"
link_file "$DOTFILES_DIR/bash/bash_aliases" "$CONFIG_DIR/bash/bash_aliases"
add_source_to_bashrc "bash_aliases"
}
# Install bash completion
install_bash_completion() {
echo "Installing bash completion..."
ensure_dir "$CONFIG_DIR/bash"
link_file "$DOTFILES_DIR/bash/bash_completion" "$CONFIG_DIR/bash/bash_completion"
add_source_to_bashrc "bash_completion"
}
# Install bash environment
install_bash_env() {
echo "Installing bash environment..."
ensure_dir "$CONFIG_DIR/bash"
link_file "$DOTFILES_DIR/bash/bash_env" "$CONFIG_DIR/bash/bash_env"
add_source_to_bashrc "bash_env"
}
# Install bash functions
install_bash_functions() {
echo "Installing bash functions..."
ensure_dir "$CONFIG_DIR/bash"
link_file "$DOTFILES_DIR/bash/bash_functions" "$CONFIG_DIR/bash/bash_functions"
add_source_to_bashrc "bash_functions"
}
# Install fedora aliases
install_bash_fedora() {
echo "Installing fedora aliases..."
ensure_dir "$CONFIG_DIR/bash"
link_file "$DOTFILES_DIR/bash/fedora_aliases" "$CONFIG_DIR/bash/fedora_aliases"
add_source_to_bashrc "fedora_aliases"
}
# Install bash configuration (all components)
install_bash() {
echo "Installing all bash configuration..."
install_bash_aliases
install_bash_completion
install_bash_env
install_bash_functions
install_bash_fedora
# Create a .bash_dir symlink in home directory for compatibility
link_file "$CONFIG_DIR/bash" "$HOME/.bash_dir"
}
# Install borg backup profiles
install_borg() {
echo "Installing borg backup profiles..."
ensure_dir "$CONFIG_DIR/borg"
link_file "$DOTFILES_DIR/borg-backup-profiles" "$CONFIG_DIR/borg"
}
# Install fish configuration
install_fish() {
echo "Installing fish configuration..."
ensure_dir "$CONFIG_DIR"
link_file "$DOTFILES_DIR/fish" "$CONFIG_DIR/fish"
}
# Install ghostty configuration
install_ghostty() {
echo "Installing ghostty configuration..."
ensure_dir "$CONFIG_DIR"
link_file "$DOTFILES_DIR/ghostty" "$CONFIG_DIR/ghostty"
}
# Install git configuration
install_git() {
echo "Installing git configuration..."
link_file "$DOTFILES_DIR/git/gitconfig" "$HOME/.gitconfig"
}
# Install neovim configuration
install_nvim() {
echo "Installing neovim configuration..."
ensure_dir "$CONFIG_DIR"
link_file "$DOTFILES_DIR/nvim" "$CONFIG_DIR/nvim"
}
# Install rsync filter rules
install_rsync() {
echo "Installing rsync filter rules..."
link_file "$DOTFILES_DIR/sync-filter-fedora/dot-rsync-filter-home" "$HOME/.rsync-filter-home"
}
# Install starship configuration
install_starship() {
echo "Installing starship configuration..."
ensure_dir "$CONFIG_DIR"
link_file "$DOTFILES_DIR/dot-config/starship.toml" "$CONFIG_DIR/starship.toml"
}
# Install tmux configuration
install_tmux() {
echo "Installing tmux configuration..."
link_file "$DOTFILES_DIR/tmux/tmux.conf" "$HOME/.tmux.conf"
}
# Install vim configuration
install_vim() {
echo "Installing vim configuration..."
link_file "$DOTFILES_DIR/vim/vimrc" "$HOME/.vimrc"
ensure_dir "$HOME/.vim"
link_file "$DOTFILES_DIR/vim/initvim" "$HOME/.vim/init.vim"
}
# Install zellij configuration
install_zellij() {
echo "Installing zellij configuration..."
ensure_dir "$CONFIG_DIR/zellij"
link_file "$DOTFILES_DIR/dot-config/zellij.kdl" "$CONFIG_DIR/zellij/config.kdl"
}
# Install zsh configuration
install_zsh() {
echo "Installing zsh configuration..."
link_file "$DOTFILES_DIR/zsh/zshrc" "$HOME/.zshrc"
}
# Install all packages
install_all() {
install_bash
install_borg
install_fish
install_ghostty
install_git
install_nvim
install_rsync
install_starship
install_tmux
install_vim
install_zellij
install_zsh
}
# Parse command line arguments
if [ $# -eq 0 ]; then
usage
fi
for arg in "$@"; do
case "$arg" in
bash) install_bash ;;
bash:aliases) install_bash_aliases ;;
bash:completion) install_bash_completion ;;
bash:env) install_bash_env ;;
bash:functions) install_bash_functions ;;
bash:fedora) install_bash_fedora ;;
borg) install_borg ;;
fish) install_fish ;;
ghostty) install_ghostty ;;
git) install_git ;;
nvim) install_nvim ;;
rsync) install_rsync ;;
starship) install_starship ;;
tmux) install_tmux ;;
vim) install_vim ;;
zellij) install_zellij ;;
zsh) install_zsh ;;
all) install_all ;;
*) echo "Unknown package: $arg"; usage ;;
esac
done
echo "Installation complete!"

View File

@ -1,145 +0,0 @@
#!/bin/sh
# test-dot-install: Test the dot-install script in an isolated environment
set -e
# Create temporary test environment
TEST_HOME=$(mktemp -d)
TEST_CONFIG="$TEST_HOME/.config"
ORIGINAL_HOME=$HOME
DOTFILES_DIR="$(cd "$(dirname "$0")" && pwd)"
SCRIPT="$DOTFILES_DIR/dot-install"
# Ensure cleanup of test environment
cleanup() {
HOME=$ORIGINAL_HOME
rm -rf "$TEST_HOME"
echo "Cleaned up test environment"
}
trap cleanup EXIT
# Color output
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Helper functions
assert() {
if [ "$1" = "$2" ]; then
printf "${GREEN}✓ PASS:${NC} $3\n"
else
printf "${RED}✗ FAIL:${NC} $3 (Expected '$2', got '$1')\n"
FAILED=1
fi
}
assert_file_exists() {
if [ -e "$1" ]; then
printf "${GREEN}✓ PASS:${NC} File exists: $1\n"
else
printf "${RED}✗ FAIL:${NC} File does not exist: $1\n"
FAILED=1
fi
}
assert_symlink() {
if [ -L "$1" ]; then
local target=$(readlink "$1")
if [ "$target" = "$2" ]; then
printf "${GREEN}✓ PASS:${NC} Symlink correct: $1 -> $2\n"
else
printf "${RED}✗ FAIL:${NC} Symlink target mismatch for $1. Expected: $2, Got: $target\n"
FAILED=1
fi
else
printf "${RED}✗ FAIL:${NC} Not a symlink: $1\n"
FAILED=1
fi
}
# Start testing
echo "Starting dot-install tests in isolated environment: $TEST_HOME"
FAILED=0
HOME="$TEST_HOME"
mkdir -p "$TEST_CONFIG"
# Create a mock .bashrc for testing source additions
echo "# Mock .bashrc file" > "$TEST_HOME/.bashrc"
# Test 1: Install bash aliases only
echo "\nTest 1: Installing bash:aliases only"
"$SCRIPT" bash:aliases
assert_file_exists "$TEST_CONFIG/bash"
assert_file_exists "$TEST_CONFIG/bash/bash_aliases"
assert_symlink "$TEST_CONFIG/bash/bash_aliases" "$DOTFILES_DIR/bash/bash_aliases"
# Check .bashrc was updated
grep -q "source \$HOME/.config/bash/bash_aliases" "$TEST_HOME/.bashrc"
if [ $? -eq 0 ]; then
printf "${GREEN}✓ PASS:${NC} .bashrc correctly updated for bash_aliases\n"
else
printf "${RED}✗ FAIL:${NC} .bashrc not updated for bash_aliases\n"
FAILED=1
fi
# Test 2: Install full bash
echo "\nTest 2: Installing full bash package"
"$SCRIPT" bash
assert_file_exists "$TEST_CONFIG/bash/bash_aliases"
assert_file_exists "$TEST_CONFIG/bash/bash_completion"
assert_file_exists "$TEST_CONFIG/bash/bash_env"
assert_file_exists "$TEST_CONFIG/bash/bash_functions"
assert_file_exists "$TEST_CONFIG/bash/fedora_aliases"
assert_symlink "$HOME/.bash_dir" "$TEST_CONFIG/bash"
# Test 3: Install nvim
echo "\nTest 3: Installing nvim package"
"$SCRIPT" nvim
assert_symlink "$TEST_CONFIG/nvim" "$DOTFILES_DIR/nvim"
# Test 4: Install git
echo "\nTest 4: Installing git package"
"$SCRIPT" git
assert_symlink "$TEST_HOME/.gitconfig" "$DOTFILES_DIR/git/gitconfig"
# Test 5: Install starship
echo "\nTest 5: Installing starship package"
"$SCRIPT" starship
assert_symlink "$TEST_CONFIG/starship.toml" "$DOTFILES_DIR/dot-config/starship.toml"
# Test 6: Install zellij
echo "\nTest 6: Installing zellij package"
"$SCRIPT" zellij
assert_file_exists "$TEST_CONFIG/zellij"
assert_symlink "$TEST_CONFIG/zellij/config.kdl" "$DOTFILES_DIR/dot-config/zellij.kdl"
# Test 7: Test idempotence (installing twice)
echo "\nTest 7: Testing idempotence (installing twice)"
# Redirect output to suppress it during the second run
"$SCRIPT" git > /dev/null
assert_symlink "$TEST_HOME/.gitconfig" "$DOTFILES_DIR/git/gitconfig"
# Test 8: Test backup functionality
echo "\nTest 8: Testing backup functionality"
echo "test content" > "$TEST_HOME/.tmux.conf"
"$SCRIPT" tmux
assert_file_exists "$TEST_HOME/.tmux.conf.bak"
assert_symlink "$TEST_HOME/.tmux.conf" "$DOTFILES_DIR/tmux/tmux.conf"
# Report results
echo "\nTest Summary:"
if [ $FAILED -eq 0 ]; then
printf "${GREEN}All tests passed!${NC}\n"
exit 0
else
printf "${RED}$FAILED tests failed!${NC}\n"
exit 1
fi