#!/usr/bin/env bash set -e # the path to dir where the script and dotfiles are located # set to specific path so this script can be run from anywhere dotfilesPath="$HOME/.dotfiles" h() { # ln -sf and logs path ln -sf "$1" "$2" echo "[ln] $2" } mkd() { # mkdir -p and logs path mkdir -p "$1" echo "[mkdir] $1" } create_links_in_dir_recursively() { local base_dir="$dotfilesPath/$1" local target_dir="$2" find "$base_dir/" -type d | while read -r dir; do mkd "$HOME/$target_dir${dir#"$base_dir"}" find "$dir" -maxdepth 1 -type f | while read -r file; do h "$file" "$HOME/$target_dir${file#"$base_dir"}" done done } h "$dotfilesPath/tmux.conf" "$HOME/.tmux.conf" mkd "$HOME/bin/" find "$dotfilesPath/bin" -type f -exec ln -sf {} "$HOME/bin/" \; create_links_in_dir_recursively "config" ".config"