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