fix manage configs .sh
This commit is contained in:
45
fix_links.sh
45
fix_links.sh
@ -1,45 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# A script to REMOVE old broken links and CREATE correct new ones.
|
||||
|
||||
DOTFILES_DIR="$HOME/dotfiles"
|
||||
CONFIG_DIR="$HOME/.config"
|
||||
|
||||
# List of all config DIRECTORIES to be linked into ~/.config
|
||||
CONFIG_DIRS=(
|
||||
"atuin" "borg" "btop" "carapace" "gh" "ghostty"
|
||||
"kitty" "lazygit" "nushell" "nvim" "zellij"
|
||||
)
|
||||
|
||||
echo "--- Starting to fix symbolic links ---"
|
||||
|
||||
# --- 1. Fix links for directories inside ~/.config ---
|
||||
for dir in "${CONFIG_DIRS[@]}"; do
|
||||
SOURCE_PATH="$DOTFILES_DIR/$dir"
|
||||
LINK_PATH="$CONFIG_DIR/$dir"
|
||||
|
||||
echo "-> Processing $dir..."
|
||||
# Remove any existing file or broken link at the destination
|
||||
rm -rf "$LINK_PATH"
|
||||
# Create the new, correct symlink
|
||||
ln -s "$SOURCE_PATH" "$LINK_PATH"
|
||||
echo " Linked $SOURCE_PATH -> $LINK_PATH"
|
||||
done
|
||||
|
||||
# --- 2. Fix link for starship.toml file in ~/.config ---
|
||||
SOURCE_PATH_STARSHIP="$DOTFILES_DIR/starship.toml"
|
||||
LINK_PATH_STARSHIP="$CONFIG_DIR/starship.toml"
|
||||
echo "-> Processing starship.toml..."
|
||||
rm -f "$LINK_PATH_STARSHIP"
|
||||
ln -s "$SOURCE_PATH_STARSHIP" "$LINK_PATH_STARSHIP"
|
||||
echo " Linked $SOURCE_PATH_STARSHIP -> $LINK_PATH_STARSHIP"
|
||||
|
||||
# --- 3. Fix link for .zshrc file in ~ ---
|
||||
SOURCE_PATH_ZSHRC="$DOTFILES_DIR/.zshrc"
|
||||
LINK_PATH_ZSHRC="$HOME/.zshrc"
|
||||
echo "-> Processing .zshrc..."
|
||||
rm -f "$LINK_PATH_ZSHRC"
|
||||
ln -s "$SOURCE_PATH_ZSHRC" "$LINK_PATH_ZSHRC"
|
||||
echo " Linked $SOURCE_PATH_ZSHRC -> $LINK_PATH_ZSHRC"
|
||||
|
||||
echo "--- All links have been reset correctly. ---"
|
||||
@ -1,76 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
# A script to back up, move, and symlink configuration files/directories
|
||||
# from ~/.config to the dotfiles repository.
|
||||
# A script to REMOVE old broken links and CREATE correct new ones.
|
||||
|
||||
# --- Configuration ---
|
||||
# Source directory for configs
|
||||
CONFIG_DIR="$HOME/.config"
|
||||
# Destination directory within the dotfiles repo
|
||||
DOTFILES_DIR="$HOME/dotfiles"
|
||||
CONFIG_DIR="$HOME/.config"
|
||||
|
||||
# List of DIRECTORIES to manage
|
||||
DIRS_TO_MANAGE=(
|
||||
"atuin"
|
||||
"borg"
|
||||
"btop"
|
||||
"carapace"
|
||||
"gh"
|
||||
"ghostty"
|
||||
"kitty"
|
||||
"lazygit"
|
||||
"nushell"
|
||||
"zellij"
|
||||
# List of all config DIRECTORIES to be linked into ~/.config
|
||||
CONFIG_DIRS=(
|
||||
"atuin" "borg" "btop" "carapace" "gh" "ghostty"
|
||||
"kitty" "lazygit" "nushell" "nvim" "zellij"
|
||||
)
|
||||
|
||||
# List of FILES to manage
|
||||
FILES_TO_MANAGE=(
|
||||
"starship.toml"
|
||||
)
|
||||
# --- End of Configuration ---
|
||||
echo "--- Starting to fix symbolic links ---"
|
||||
|
||||
# Ensure the target directory for configs exists in the dotfiles repo
|
||||
mkdir -p "$DOTFILES_DIR/.config"
|
||||
TARGET_DIR="$DOTFILES_DIR/.config"
|
||||
# --- 1. Fix links for directories inside ~/.config ---
|
||||
for dir in "${CONFIG_DIRS[@]}"; do
|
||||
SOURCE_PATH="$DOTFILES_DIR/$dir"
|
||||
LINK_PATH="$CONFIG_DIR/$dir"
|
||||
|
||||
echo "Starting configuration management..."
|
||||
|
||||
# --- Process Directories ---
|
||||
for dir in "${DIRS_TO_MANAGE[@]}"; do
|
||||
SOURCE_PATH="$CONFIG_DIR/$dir"
|
||||
# Check if the source is a real directory and not already a symlink
|
||||
if [ -d "$SOURCE_PATH" ] && [ ! -L "$SOURCE_PATH" ]; then
|
||||
echo " -> Processing directory: $dir"
|
||||
echo " - Backing up to ${SOURCE_PATH}.bak"
|
||||
cp -r "$SOURCE_PATH" "$SOURCE_PATH.bak"
|
||||
|
||||
echo " - Moving to $TARGET_DIR"
|
||||
mv "$SOURCE_PATH" "$TARGET_DIR/"
|
||||
|
||||
echo " - Creating symlink at $SOURCE_PATH"
|
||||
ln -s "$TARGET_DIR/$dir" "$SOURCE_PATH"
|
||||
else
|
||||
echo " -> Skipping $dir (does not exist or is already a symlink)."
|
||||
fi
|
||||
echo "-> Processing $dir..."
|
||||
# Remove any existing file or broken link at the destination
|
||||
rm -rf "$LINK_PATH"
|
||||
# Create the new, correct symlink
|
||||
ln -s "$SOURCE_PATH" "$LINK_PATH"
|
||||
echo " Linked $SOURCE_PATH -> $LINK_PATH"
|
||||
done
|
||||
|
||||
# --- Process Files ---
|
||||
for file in "${FILES_TO_MANAGE[@]}"; do
|
||||
SOURCE_PATH="$CONFIG_DIR/$file"
|
||||
# Check if the source is a real file and not already a symlink
|
||||
if [ -f "$SOURCE_PATH" ] && [ ! -L "$SOURCE_PATH" ]; then
|
||||
echo " -> Processing file: $file"
|
||||
echo " - Backing up to ${SOURCE_PATH}.bak"
|
||||
cp "$SOURCE_PATH" "$SOURCE_PATH.bak"
|
||||
# --- 2. Fix link for starship.toml file in ~/.config ---
|
||||
SOURCE_PATH_STARSHIP="$DOTFILES_DIR/starship.toml"
|
||||
LINK_PATH_STARSHIP="$CONFIG_DIR/starship.toml"
|
||||
echo "-> Processing starship.toml..."
|
||||
rm -f "$LINK_PATH_STARSHIP"
|
||||
ln -s "$SOURCE_PATH_STARSHIP" "$LINK_PATH_STARSHIP"
|
||||
echo " Linked $SOURCE_PATH_STARSHIP -> $LINK_PATH_STARSHIP"
|
||||
|
||||
echo " - Moving to $TARGET_DIR"
|
||||
mv "$SOURCE_PATH" "$TARGET_DIR/"
|
||||
# --- 3. Fix link for .zshrc file in ~ ---
|
||||
SOURCE_PATH_ZSHRC="$DOTFILES_DIR/.zshrc"
|
||||
LINK_PATH_ZSHRC="$HOME/.zshrc"
|
||||
echo "-> Processing .zshrc..."
|
||||
rm -f "$LINK_PATH_ZSHRC"
|
||||
ln -s "$SOURCE_PATH_ZSHRC" "$LINK_PATH_ZSHRC"
|
||||
echo " Linked $SOURCE_PATH_ZSHRC -> $LINK_PATH_ZSHRC"
|
||||
|
||||
echo " - Creating symlink at $SOURCE_PATH"
|
||||
ln -s "$TARGET_DIR/$file" "$SOURCE_PATH"
|
||||
else
|
||||
echo " -> Skipping $file (does not exist or is already a symlink)."
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Process complete."
|
||||
echo "--- All links have been reset correctly. ---"
|
||||
|
||||
@ -50,3 +50,6 @@ yazi ~/dotfiles
|
||||
rm ~/.config/nvim
|
||||
~/dotfiles/fix_links.sh
|
||||
cd ~/dotfiles
|
||||
lazygit
|
||||
rm ~/dotfiles/manage_configs.sh
|
||||
mv ~/dotfiles/fix_links.sh ~/dotfiles/manage_configs.sh
|
||||
|
||||
Reference in New Issue
Block a user