Problem
When dotfiles are renamed or removed from the repository, broken symlinks can remain in the home directory. These broken symlinks point to non-existent files and can cause confusion or errors.
For example:
- If we rename
vimrc to vim_config, the old ~/.vimrc symlink becomes broken
- If we remove a dotfile from the repository, its corresponding
~/.dotfile symlink becomes invalid
- Currently, there's no automated way to detect and clean up these broken symlinks
Proposed Solution
Add a new Makefile target clean-broken-symlinks that:
- Detects broken dotfile symlinks in the home directory (
~/.??*)
- Filters for repository-related symlinks (pointing to this dotfiles repository)
- Interactively prompts for each broken symlink deletion
- Shows clear information about what will be removed
Suggested implementation:
clean-broken-symlinks:
@echo "Checking for broken dotfile symlinks in home directory..."
@for link in ~/.??* ; do \
if [ -L "$$link" ] && ! [ -e "$$link" ] ; then \
target=$$(readlink "$$link") ; \
if [[ "$$target" == "$(CURDIR)"/* ]] ; then \
echo "Found broken symlink: $$link -> $$target" ; \
read -p "Remove $$link? [y/N]: " confirm ; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ] ; then \
rm -v "$$link" ; \
fi ; \
fi ; \
fi ; \
done
Features:
- Safe: Only targets symlinks pointing to this dotfiles repository
- Interactive: Asks for confirmation before each deletion
- Informative: Shows what symlink points where
- Non-destructive: Skips regular files and valid symlinks
Usage:
make clean-broken-symlinks
This would help maintain a clean home directory and prevent issues caused by stale symlinks.
Problem
When dotfiles are renamed or removed from the repository, broken symlinks can remain in the home directory. These broken symlinks point to non-existent files and can cause confusion or errors.
For example:
vimrctovim_config, the old~/.vimrcsymlink becomes broken~/.dotfilesymlink becomes invalidProposed Solution
Add a new Makefile target
clean-broken-symlinksthat:~/.??*)Suggested implementation:
Features:
Usage:
This would help maintain a clean home directory and prevent issues caused by stale symlinks.