-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
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
vimrctovim_config, the old~/.vimrcsymlink becomes broken - If we remove a dotfile from the repository, its corresponding
~/.dotfilesymlink 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 ; \
doneFeatures:
- 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-symlinksThis would help maintain a clean home directory and prevent issues caused by stale symlinks.
Metadata
Metadata
Assignees
Labels
No labels