feat: Update dotfiles
This commit is contained in:
parent
755b457cc6
commit
b31334a1c1
102
dotfiles.sh
102
dotfiles.sh
@ -2,71 +2,55 @@ cd ~/.dotfiles
|
|||||||
git pull
|
git pull
|
||||||
echo "Creating symbolic links for dotfiles..."
|
echo "Creating symbolic links for dotfiles..."
|
||||||
|
|
||||||
|
dirs_to_sym = (".config/alacritty/themes" ".zsh_functions")
|
||||||
|
sub_modules = (".config/alacritty/themes")
|
||||||
|
|
||||||
# Function to create symlinks recursively
|
# Function to create symlinks recursively
|
||||||
create_symlinks() {
|
create_symlinks() {
|
||||||
local src_dir="$1"
|
local src_dir="$1"
|
||||||
local target_dir="$2"
|
local target_dir="$2"
|
||||||
|
|
||||||
# Create the target directory if it doesn't exist
|
|
||||||
mkdir -p "$target_dir"
|
|
||||||
|
|
||||||
# Handle .zsh_functions directory specially - link the whole directory
|
|
||||||
if [ -d "$src_dir/.zsh_functions" ]; then
|
|
||||||
local target_zsh_functions="$target_dir/.zsh_functions"
|
|
||||||
|
|
||||||
# Remove existing directory or symlink if it exists
|
|
||||||
if [ -e "$target_zsh_functions" ] || [ -L "$target_zsh_functions" ]; then
|
|
||||||
echo "Removing existing: $target_zsh_functions"
|
|
||||||
rm -rf "$target_zsh_functions"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create symlink for the entire directory
|
|
||||||
echo "Linking directory: $src_dir/.zsh_functions -> $target_zsh_functions"
|
|
||||||
ln -s "$src_dir/.zsh_functions" "$target_zsh_functions"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Find all files and directories in the source directory, excluding .git, README.md, and .zsh_functions
|
# Create the target directory if it doesn't exist
|
||||||
find "$src_dir" \( -not -path "*/\.git*" -and -not -name "README.md" -and -not -path "*/.zsh_functions/*" -and -not -path "*/.zsh_functions" \) -and \( -type f -o -type l \) | while read -r src_file; do
|
mkdir -p "$target_dir"
|
||||||
# Get the relative path from src_dir
|
# For each file
|
||||||
rel_path="${src_file#$src_dir/}"
|
for file in "$src_dir"/*; do
|
||||||
|
# Get the file name
|
||||||
# Construct the target file path
|
local file_name=$(basename "$file")
|
||||||
target_file="$target_dir/$rel_path"
|
# If the file is a directory
|
||||||
|
if [ -d "$file" ]; then
|
||||||
# Create parent directories if they don't exist
|
# Check if the directory is in the list of directories to symlink
|
||||||
mkdir -p "$(dirname "$target_file")"
|
if [[ " ${dirs_to_sym[@]} " =~ " $file_name " ]]; then
|
||||||
|
# If the directory is in the list, create a symlink
|
||||||
# Remove existing file if it exists
|
echo "Linking directory: $file -> $target_dir/$file_name"
|
||||||
if [ -e "$target_file" ] || [ -L "$target_file" ]; then
|
ln -s "$file" "$target_dir/$file_name"
|
||||||
echo "Removing existing file: $target_file"
|
else
|
||||||
rm -f "$target_file"
|
# If the directory is not in the list, recursively call the function
|
||||||
fi
|
create_symlinks "$file" "$target_dir/$file_name"
|
||||||
|
fi
|
||||||
# Create symlink
|
else
|
||||||
echo "Linking: $src_file -> $target_file"
|
# If the file is not a symlink
|
||||||
ln -s "$src_file" "$target_file"
|
if [ ! -L "$target_dir/$file_name" ]; then
|
||||||
done
|
# If the file exists
|
||||||
|
if [ -e "$target_dir/$file_name" ]; then
|
||||||
# Handle .config/alacritty/themes directory specially - link the whole directory
|
# Remove the file
|
||||||
if [ -d "$src_dir/.config/alacritty/themes" ]; then
|
echo "Removing existing: $target_dir/$file_name"
|
||||||
local target_alacritty_themes="$target_dir/.config/alacritty/themes"
|
rm -rf "$target_dir/$file_name"
|
||||||
|
fi
|
||||||
# Remove existing directory or symlink if it exists
|
# Create a symlink
|
||||||
if [ -e "$target_alacritty_themes" ] || [ -L "$target_alacritty_themes" ]; then
|
echo "Linking: $file -> $target_dir/$file_name"
|
||||||
echo "Removing existing: $target_alacritty_themes"
|
ln -s "$file" "$target_dir/$file_name"
|
||||||
rm -rf "$target_alacritty_themes"
|
fi
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
# Ensure .config/alacritty directory exists
|
|
||||||
mkdir -p "$target_dir/.config/alacritty"
|
|
||||||
|
|
||||||
# Make sure to pull latest changes from the repo submodules
|
# For each submodule
|
||||||
|
for submodule in "${sub_modules[@]}"; do
|
||||||
|
# cd into the submodule and git submodule update --init --recursive
|
||||||
|
cd "$src_dir/$submodule"
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
|
# cd back to the src_dir
|
||||||
# Create symlink for the entire directory
|
cd "$src_dir"
|
||||||
echo "Linking directory: $src_dir/.config/alacritty/themes -> $target_alacritty_themes"
|
done
|
||||||
ln -s "$src_dir/.config/alacritty/themes" "$target_alacritty_themes"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
8
setup.sh
8
setup.sh
@ -3,8 +3,8 @@
|
|||||||
# Install dependencies
|
# Install dependencies
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
|
|
||||||
# Python 3 and related packages
|
# Python 3 and dependencies
|
||||||
sudo apt-get install -y python3 python3-pip python3-venv curl wget
|
sudo apt-get install -y python3 python3-pip python3-venv curl wget unzip
|
||||||
|
|
||||||
# Install most stuff
|
# Install most stuff
|
||||||
sudo apt-get install -y zsh bat fzf jq knot-dnsutils tre-command polybar
|
sudo apt-get install -y zsh bat fzf jq knot-dnsutils tre-command polybar
|
||||||
@ -25,7 +25,7 @@ curl --proto '=https' --tlsv1.2 -LsSf https://setup.atuin.sh | sh
|
|||||||
cargo install eza
|
cargo install eza
|
||||||
|
|
||||||
# Install Alacritty
|
# Install Alacritty
|
||||||
sudo apt install cmake g++ pkg-config libfreetype6-dev libfontconfig1-dev libxcb-xfixes0-dev libxkbcommon-dev
|
sudo apt install -y cmake g++ pkg-config libfreetype6-dev libfontconfig1-dev libxcb-xfixes0-dev libxkbcommon-dev
|
||||||
cargo install alacritty
|
cargo install alacritty
|
||||||
# Add to menu
|
# Add to menu
|
||||||
sudo cp ./alacritty-term.svg /usr/share/pixmaps/Alacritty.svg
|
sudo cp ./alacritty-term.svg /usr/share/pixmaps/Alacritty.svg
|
||||||
@ -42,4 +42,4 @@ git clone git@woodburn.au:nathanwoodburn/dotfiles.git ~/.dotfiles
|
|||||||
git clone git@woodburn.au:nathanwoodburn/scripts.git ~/scripts
|
git clone git@woodburn.au:nathanwoodburn/scripts.git ~/scripts
|
||||||
|
|
||||||
# Install fonts
|
# Install fonts
|
||||||
sudo apt install fonts-firacode
|
sudo apt install -y fonts-firacode
|
Loading…
Reference in New Issue
Block a user