From 54fed3bd9a21b8c0bce6030ebadb09c06e763420 Mon Sep 17 00:00:00 2001 From: Pol Date: Fri, 15 May 2026 21:31:56 +0200 Subject: [PATCH 1/3] feat: update environment sourcing and linting for user paths --- .bash_profile | 5 ++- .bashrc | 5 ++- .config/nvidia/.nvidia-settings-rc | 2 +- .github/workflows/lint.yml | 54 +++++++++++++++++++++++++ .gitignore | 10 ++++- .local/Mini/.bashrc | 3 +- .local/scripts/bin/git-recurse | 5 ++- .local/scripts/bootstrap/base_functions | 8 ++-- .zshenv | 10 ++++- 9 files changed, 91 insertions(+), 11 deletions(-) diff --git a/.bash_profile b/.bash_profile index ab44562d..761bafa2 100644 --- a/.bash_profile +++ b/.bash_profile @@ -1,3 +1,6 @@ # Source .bashrc [[ -f ~/.bashrc ]] && . ~/.bashrc -. "/home/pol/.local/share/cargo/env" + +_cargo_env="${CARGO_HOME:-${XDG_DATA_HOME:-$HOME/.local/share}/cargo}/env" +[ -r "$_cargo_env" ] && . "$_cargo_env" +unset _cargo_env diff --git a/.bashrc b/.bashrc index 0fa78b10..d6f4ac77 100644 --- a/.bashrc +++ b/.bashrc @@ -73,4 +73,7 @@ if [ -f "$_zshdir/functions" ]; then source "$_zshdir/functions" fi unset _zshdir -. "/home/pol/.local/share/cargo/env" + +_cargo_env="${CARGO_HOME:-${XDG_DATA_HOME:-$HOME/.local/share}/cargo}/env" +[ -r "$_cargo_env" ] && . "$_cargo_env" +unset _cargo_env diff --git a/.config/nvidia/.nvidia-settings-rc b/.config/nvidia/.nvidia-settings-rc index f32b7506..0f150132 100644 --- a/.config/nvidia/.nvidia-settings-rc +++ b/.config/nvidia/.nvidia-settings-rc @@ -1,5 +1,5 @@ # -# /home/pol/.nvidia-settings-rc +# ~/.nvidia-settings-rc # # Configuration file for nvidia-settings - the NVIDIA X Server Settings utility # Generated on Sun Aug 9 23:07:26 2020 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index fb1253cf..63e319a9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,3 +21,57 @@ jobs: - name: Run lint run: bash .local/scripts/lint.sh + + hardcoded-paths: + name: Hardcoded user paths + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: false + + - name: Scan for /home// and /Users// in tracked files + run: | + # Fail on any tracked file containing an absolute /home// or + # /Users// path. Excludes: + # - documentation (*.md, SECURITY.md, .gitignore) where examples are fine + # - configs that are intentionally per-user runtime state and would + # otherwise need to be re-removed from git on every machine + if git grep -InE '(/home/[a-z][a-z0-9_-]*/|/Users/[a-z][a-z0-9_-]*/)' \ + -- ':!*.md' \ + ':!.gitignore' \ + ':!SECURITY.md' \ + ':!.config/warp-terminal/user_preferences.json' \ + ':!.config/birdtray-config.json' \ + ':!.config/texstudio/texstudio.ini' \ + ':!.config/texstudio/cache/' \ + ':!.config/texstudio/dictionaries/' \ + ':!.cinnamon/backgrounds/user-folders.lst' \ + ':!.config/cinnamon/dark/gnome.dconf' \ + ':!.config/cinnamon/light/gnome.dconf' \ + ':!.config/.p10k.zsh' \ + ':!.config/zsh/.p10k.zsh' \ + ':!.config/vlc/vlc-qt-interface.conf' \ + ':!.vim/.netrwhist' \ + ':!.local/scripts/bootstrap/arch_functions'; then + echo "" + echo "ERROR: hardcoded user paths found in tracked files (see above)." + echo "Use \$HOME, ~/, or XDG variables instead." + exit 1 + fi + + stow-dryrun: + name: Stow dry-run + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: false + + - name: Install stow + run: sudo apt-get update && sudo apt-get install -y stow + + - name: Dry-run stow into a scratch HOME + run: | + scratch="$(mktemp -d)" + make dry-run TARGET="$scratch" diff --git a/.gitignore b/.gitignore index ba31daee..5b0227e6 100644 --- a/.gitignore +++ b/.gitignore @@ -69,7 +69,7 @@ # Standalone files in .config/ !.config/.p10k.zsh !.config/.git-prompt-colors.sh -!.config/birdtray-config.json +# birdtray-config.json contains per-user Thunderbird mailbox paths — don't track !.config/emacs.org !.config/inputrc !.config/stick @@ -309,6 +309,10 @@ .config/texstudio/packageCache.dat .config/texstudio/template_resources.xml .config/texstudio/wordCount.usage +# texstudio.ini holds recent-files/last-document with absolute per-user paths; +# cache/ holds per-document JSON also with absolute paths +.config/texstudio/cache/ +.config/texstudio/texstudio.ini # LibreOffice runtime .config/libreoffice/4/user/GraphicsRenderTests.log @@ -338,6 +342,10 @@ # Cinnamon runtime .cinnamon/spices.cache +# Cinnamon dconf dumps regenerate on every login with absolute /home// paths +.cinnamon/backgrounds/user-folders.lst +.config/cinnamon/dark/gnome.dconf +.config/cinnamon/light/gnome.dconf # Distro (generated by bootstrap scripts) .config/distro diff --git a/.local/Mini/.bashrc b/.local/Mini/.bashrc index eb9e92b7..e7558445 100644 --- a/.local/Mini/.bashrc +++ b/.local/Mini/.bashrc @@ -148,7 +148,8 @@ pull() { for i in "${!pids[@]}"; do local pid="${pids[$i]}" repo="${repos[$i]}" - local outfile="$tmpdir/$(echo "$repo" | tr '/' '_').out" + local outfile + outfile="$tmpdir/$(echo "$repo" | tr '/' '_').out" if wait "$pid"; then printf "\033[32m✓ %s\033[0m\n" "$repo" else diff --git a/.local/scripts/bin/git-recurse b/.local/scripts/bin/git-recurse index 7bf92cd6..80fe15ef 100755 --- a/.local/scripts/bin/git-recurse +++ b/.local/scripts/bin/git-recurse @@ -59,7 +59,8 @@ function git_recursive() { for i in "${!pids[@]}"; do local pid=${pids[$i]} local dir=${dirs[$i]} - local outfile="$tmpdir/$(echo "$dir" | tr '/' '_').out" + local outfile + outfile="$tmpdir/$(echo "$dir" | tr '/' '_').out" local status=0 wait "$pid" || status=$? @@ -75,7 +76,7 @@ function git_recursive() { if [[ -s "$outfile" ]]; then sed 's/^/ /' "$outfile" else - printf " ${dim}(no output)${reset}\n" + printf " %s(no output)%s\n" "$dim" "$reset" fi done diff --git a/.local/scripts/bootstrap/base_functions b/.local/scripts/bootstrap/base_functions index b18274f0..7892f685 100644 --- a/.local/scripts/bootstrap/base_functions +++ b/.local/scripts/bootstrap/base_functions @@ -124,9 +124,11 @@ apply_skip_worktree() { info "Applying skip-worktree to volatile config files..." for f in "${files[@]}"; do if [ -f "$dotfiles_root/$f" ]; then - git -C "$dotfiles_root" update-index --skip-worktree "$f" \ - && info " skip-worktree: $f" \ - || warn " Could not apply skip-worktree to $f" + if git -C "$dotfiles_root" update-index --skip-worktree "$f"; then + info " skip-worktree: $f" + else + warn " Could not apply skip-worktree to $f" + fi else info " Skipping (not yet present): $f" fi diff --git a/.zshenv b/.zshenv index 59e62be7..a024e581 100644 --- a/.zshenv +++ b/.zshenv @@ -197,10 +197,18 @@ export ADB_VENDOR_KEY="$XDG_CONFIG_HOME"/android export GTK_RC_FILES="$XDG_CONFIG_HOME"/gtk-1.0/gtkrc export GTK2_RC_FILES="$XDG_CONFIG_HOME"/gtk-2.0/gtkrc +############################################################### +# => Cargo (sourced before local overrides so they can adjust it) +############################################################### + +_cargo_env="${CARGO_HOME:-${XDG_DATA_HOME:-$HOME/.local/share}/cargo}/env" +# shellcheck disable=SC1090 +[ -r "$_cargo_env" ] && . "$_cargo_env" +unset _cargo_env + ############################################################### # => Local overrides (machine-specific, not tracked by git) ############################################################### # shellcheck disable=SC1091 [ -r "$HOME/.zshenv.local" ] && source "$HOME/.zshenv.local" -. "/home/pol/.local/share/cargo/env" From 400f3fad9e69a47564ba8e965ee8c43dd84e98ff Mon Sep 17 00:00:00 2001 From: Pol Date: Fri, 15 May 2026 21:35:53 +0200 Subject: [PATCH 2/3] feat: add auto-fix target for markdown issues in Makefile --- .vim/vimrc | 44 +++++++++++++++++++++++--------------------- Makefile | 12 +++++++++++- README.md | 5 +++-- 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/.vim/vimrc b/.vim/vimrc index 6e566002..ab641b07 100644 --- a/.vim/vimrc +++ b/.vim/vimrc @@ -1,7 +1,9 @@ +scriptencoding utf-8 + " General {{{ " Leader key for custom key combinations -let mapleader=" " +let mapleader=' ' " Activate folds set foldmethod=marker @@ -80,18 +82,18 @@ Plug 'ycm-core/YouCompleteMe' call plug#end() "Acaben els plugins autocmd! User vim-which-key call which_key#register('', 'g:which_key_map') -let g:UltiSnipsExpandTrigger="" " insert snippet !! -let g:UltiSnipsJumpForwardTrigger="" -let g:UltiSnipsJumpBackwardTrigger="" +let g:UltiSnipsExpandTrigger='' " insert snippet !! +let g:UltiSnipsJumpForwardTrigger='' +let g:UltiSnipsJumpBackwardTrigger='' "Configuracions del plugin YouCompleteMe let g:ycm_confirm_extra_conf = 0 "Disables prompting for script every time if has('unix') - let g:ycm_clangd_binary_path = exepath("clangd") + let g:ycm_clangd_binary_path = exepath('clangd') endif if has('macunix') - let g:ycm_clangd_binary_path = exepath("clangd") + let g:ycm_clangd_binary_path = exepath('clangd') endif let g:ycm_autoclose_preview_window_after_insertion = 1 @@ -136,14 +138,14 @@ set mouse=a autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o " Set 4 lines to the cursor - when moving vertically using j/k -set so=4 " margin +set scrolloff=4 " margin " Turn on the Wild menu, better autocompletion set wildmenu " Ignore compiled files set wildignore=*.o,*~,*.pyc -if has("win16") || has("win32") +if has('win16') || has('win32') set wildignore+=.git\*,.hg\*,.svn\* else set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store @@ -211,10 +213,10 @@ let g:which_key_map.f = { 'name' : '+file' } " Use 24-bit (true-color) mode in Vim/Neovim when outside tmux IN LINUX, ( do not remove. ) if (empty($TMUX)) - if (has("nvim")) + if (has('nvim')) let $NVIM_TUI_ENABLE_TRUE_COLOR=1 endif - if (has("termguicolors")) + if (has('termguicolors')) set termguicolors endif endif @@ -222,7 +224,7 @@ endif " set t_Co=256 if exists('$TMUX') - if (has("nvim")) + if (has('nvim')) set termguicolors " Nvim colors look good on tmux with this else endif @@ -246,13 +248,13 @@ set fileencoding=utf-8 let g:airline#extensions#tabline#enabled = 1 "fica automaticament els buffers a la barreta " Use Unix as the standard file type -set ffs=unix,dos,mac +set fileformats=unix,dos,mac " :help updatetime set updatetime=1500 " Set font for gvim -if has("gui_running") +if has('gui_running') set guifont=SauceCodePro\ Nerd\ Font\ 11 endif " }}} @@ -283,11 +285,11 @@ set shiftwidth=4 set tabstop=4 " Linebreak on 500 characters -set lbr -set tw=500 +set linebreak +set textwidth=500 -set ai "Auto indent -set si "Smart indent +set autoindent "Auto indent +set smartindent "Smart indent set wrap "Wrap lines set breakindent "Indent after line wrapped "}}} @@ -296,14 +298,14 @@ set breakindent "Indent after line wrapped nmap tt :TagbarToggle function! GotoJump() jumps - let j = input("Please select your jump: ") + let j = input('Please select your jump: ') if j != '' let pattern = '\v\c^\+' if j =~ pattern let j = substitute(j, pattern, '', 'g') - execute "normal " . j . "\" + execute 'normal ' . j . "\" else - execute "normal " . j . "\" + execute 'normal ' . j . "\" endif endif endfunction @@ -449,7 +451,7 @@ map ? z= """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Nerd Tree """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -let g:NERDTreeWinPos = "right" +let g:NERDTreeWinPos = 'right' let NERDTreeShowHidden=0 let g:NERDTreeWinSize=35 """""""""""""""""""""""""""""" diff --git a/Makefile b/Makefile index 6b81bb70..1958cb8b 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ STOW := stow STOW_DIR := $(shell pwd) TARGET := $(HOME) -.PHONY: help install uninstall restow dry-run lint check hooks update submodules antigen-update skip-worktree bootstrap-arch bootstrap-manjaro bootstrap-ubuntu bootstrap-mac bootstrap-work +.PHONY: help install uninstall restow dry-run lint check fix hooks update submodules antigen-update skip-worktree bootstrap-arch bootstrap-manjaro bootstrap-ubuntu bootstrap-mac bootstrap-work help: ## Show this help @grep -E '^[a-zA-Z_-]+:.*##' $(MAKEFILE_LIST) | \ @@ -55,6 +55,16 @@ check: lint ## Run all linters (shellcheck + markdownlint + vint) @echo "" @echo "==> All checks complete." +fix: ## Auto-fix markdown issues (markdownlint --fix) + @if command -v markdownlint-cli2 >/dev/null 2>&1; then \ + markdownlint-cli2 --fix README.md .local/README.md .local/xdg/wallpapers/README.md; \ + elif command -v markdownlint >/dev/null 2>&1; then \ + markdownlint --fix README.md .local/README.md .local/xdg/wallpapers/README.md; \ + else \ + echo "markdownlint not found (npm install -g markdownlint-cli2)"; \ + exit 1; \ + fi + hooks: ## Install git pre-commit hook (runs shellcheck on staged files) cp .local/scripts/hooks/pre-commit .git/hooks/pre-commit chmod +x .git/hooks/pre-commit diff --git a/README.md b/README.md index 49b16823..64d1f804 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,8 @@ Opinionated defaults. This repo is not meant to be used by everyone, just a pers ## How it works ### Why `dotfiles/dotfiles`? -You might wonder why the repository isn't just cloned directly into `~/dotfiles`. The nested `~/dotfiles/dotfiles` structure is required by how **[GNU Stow](https://www.gnu.org/software/stow/)** manages packages. Stow expects a "stow directory" (the parent, `~/dotfiles`) containing one or more "packages" (the child, `dotfiles`, which is this repo). + +You might wonder why the repository isn't just cloned directly into `~/dotfiles`. The nested `~/dotfiles/dotfiles` structure is required by how **[GNU Stow](https://www.gnu.org/software/stow/)** manages packages. Stow expects a "stow directory" (the parent, `~/dotfiles`) containing one or more "packages" (the child, `dotfiles`, which is this repo). By cloning into `~/dotfiles/dotfiles`, stow correctly treats the inner `dotfiles` folder as the package name, allowing it to safely symlink the contents (like `.config/`, `.vim/`) directly into your `$HOME` directory without confusing the repository root with the target deployment. @@ -140,7 +141,7 @@ scripts directory. ## What's inside | Category | Tool / Config | Notes | -|---|---|---| +| --- | --- | --- | | **Shells** | zsh (antigen, p10k), bash | XDG-compliant `$ZDOTDIR` in `.config/zsh/` | | **Editors** | Vim, Neovim, Doom Emacs, personal Emacs (chemacs) | Vim config at `.vim/vimrc`; Emacs literate config in `.config/emacs.org` | | **Terminals** | kitty, Alacritty, termite | | From 0cdfd05d92b4eb35086b8fe4140bfac67e5355e8 Mon Sep 17 00:00:00 2001 From: Pol Date: Fri, 15 May 2026 21:36:42 +0200 Subject: [PATCH 3/3] fix: restore scriptencoding setting in vimrc for proper encoding --- .vim/vimrc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.vim/vimrc b/.vim/vimrc index ab641b07..5a00980b 100644 --- a/.vim/vimrc +++ b/.vim/vimrc @@ -1,5 +1,3 @@ -scriptencoding utf-8 - " General {{{ " Leader key for custom key combinations @@ -242,6 +240,7 @@ syntax on " Set utf8 as standard encoding and en_US as the standard language set encoding=utf8 +scriptencoding utf-8 set fileencoding=utf-8 " Configuració per a vim-airline