+ Enable Script

+ Disable Script
This commit is contained in:
Daniel Legt 2023-12-04 21:12:32 +02:00
parent c9e4f68ba1
commit cf0dc42413
2 changed files with 90 additions and 0 deletions

44
scripts/disable_all.sh Normal file
View File

@ -0,0 +1,44 @@
#!/bin/bash
# Store the current working directory
CURRENT_DIR="$(pwd)"
# Symlink VSCode settings.json to your VSCode configuration folder
VS_CODE_SETTINGS_DIR="$HOME/.config/Code/User"
VS_CODE_SETTINGS_FILE="$CURRENT_DIR/configs/vscode/settings.json"
BACKUP_VS_CODE_SETTINGS_FILE="$CURRENT_DIR/configs/vscode/settings.json.backup"
# Remove symlink and restore backup if it exists
if [ -L "$VS_CODE_SETTINGS_FILE" ]; then
rm "$VS_CODE_SETTINGS_FILE"
echo "Removed symlink to VSCode settings.json"
if [ -f "$BACKUP_VS_CODE_SETTINGS_FILE" ]; then
mv "$BACKUP_VS_CODE_SETTINGS_FILE" "$VS_CODE_SETTINGS_FILE"
echo "Restored original VSCode settings from $BACKUP_VS_CODE_SETTINGS_FILE"
fi
fi
# Remove sourcing of .bashrc.k from ~/.bashrc
BASHRC_FILE="$HOME/.bashrc"
BASHRC_K_FILE="$CURRENT_DIR/configs/bash/.bashrc.k"
BACKUP_BASHRC_FILE="$CURRENT_DIR/configs/bash/.bashrc.backup"
if grep -q ".bashrc.k" "$BASHRC_FILE"; then
# Remove the line that sources .bashrc.k
sed -i '/\.bashrc\.k/d' "$BASHRC_FILE"
echo "Removed sourcing of .bashrc.k from $BASHRC_FILE"
# Restore the original .bashrc if it exists
if [ -f "$BACKUP_BASHRC_FILE" ]; then
cp "$BACKUP_BASHRC_FILE" "$BASHRC_FILE"
echo "Restored original .bashrc from $BACKUP_BASHRC_FILE"
fi
else
echo "Warning: .bashrc does not source .bashrc.k. No action taken."
fi
# Go back to the original working directory
cd "$CURRENT_DIR"
echo "All settings disabled. Changes reverted if applicable."

46
scripts/enable_all.sh Normal file
View File

@ -0,0 +1,46 @@
#!/bin/bash
# Store the current working directory
CURRENT_DIR="$(pwd)"
# === [ VSCode ] ===
# Symlink VSCode settings.json to your VSCode configuration folder
VS_CODE_SETTINGS_DIR="$HOME/.config/Code/User"
VS_CODE_SETTINGS_FILE="$CURRENT_DIR/configs/vscode/settings.json"
BACKUP_VS_CODE_SETTINGS_FILE="$CURRENT_DIR/configs/vscode/settings.json.backup"
# Backup existing VSCode settings if they exist
if [ -f "$VS_CODE_SETTINGS_FILE" ]; then
mv "$VS_CODE_SETTINGS_FILE" "$BACKUP_VS_CODE_SETTINGS_FILE"
echo "Backed up existing VSCode settings to $BACKUP_VS_CODE_SETTINGS_FILE"
fi
ln -s "$VS_CODE_SETTINGS_FILE" "$VS_CODE_SETTINGS_DIR/settings.json"
echo "Symlinked VSCode settings.json to $VS_CODE_SETTINGS_DIR"
# === [ BashRC ] ===
# Add sourcing of .bashrc.k to ~/.bashrc
BASHRC_FILE="$HOME/.bashrc"
BASHRC_K_FILE="$CURRENT_DIR/configs/bash/.bashrc.k"
BACKUP_BASHRC_FILE="$CURRENT_DIR/configs/bash/.bashrc.backup"
# Backup existing .bashrc if it exists
if [ -f "$BASHRC_FILE" ]; then
cp "$BASHRC_FILE" "$BACKUP_BASHRC_FILE"
echo "Backed up existing .bashrc to $BACKUP_BASHRC_FILE"
fi
# Check if .bashrc already sources .bashrc.k
if grep -q ".bashrc.k" "$BASHRC_FILE"; then
echo "Warning: .bashrc already sources .bashrc.k"
else
echo -e "\n# Source .bashrc.k\nsource \"$BASHRC_K_FILE\"" >> "$BASHRC_FILE"
echo "Added sourcing of .bashrc.k to $BASHRC_FILE"
fi
# Go back to the original working directory
cd "$CURRENT_DIR"
echo "All settings enabled. Changes applied."