#!/bin/zsh execute() { log "execute $@" && "$@" } log() { echo "$@" } copy_dir() { local from=$1 local to=$2 pushd $from > /dev/null local dirs=(`find . -mindepth 1 -maxdepth 1 -type d`) for dir in $dirs; do [[ -d $to/$dir ]] && execute rm -rf $to/$dir execute cp -rp $dir $to/$dir done popd > /dev/null } copy_file() { local from=$1 local to=$2 local filename=$(basename $from) [[ -e $to/$filename ]] && execute rm $to/$filename execute cp -p $from $to/$filename } log "---------------- dotfiles ----------------" copy_dir src_files/.config $XDG_CONFIG_HOME copy_dir src_files/.local $DIR_LOCAL # duplicate, but copy anyway, ensures set if zsh isn't yet looking to $XDG_CONFIG_HOME/zsh copy_file src_files/.config/zsh/.zshenv $HOME # on macos, handle sim-linking to gimp config since gimp defaults to app-support if [[ "$BOX_SETUP_OS" = "macos" ]]; then local macos_gimp_dir="$HOME/Library/Application Support/GIMP" log "deleting existing GIMP link/dir: $macos_gimp_dir" [[ -h "$macos_gimp_dir" ]] && rm $macos_gimp_dir [[ -d "$macos_gimp_dir" ]] && rm -rf $macos_gimp_dir log "linking $macos_gimp_dir to \$XDG_CONFIG_HOME/GIMP" ln -s $XDG_CONFIG_HOME/GIMP $macos_gimp_dir fi