Files
dotfiles/dev-env

69 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Adapted from https://github.com/ThePrimeagen/dev/blob/master/dev-env
dry_run="0"
if [ -z "$XDG_CONFIG_HOME" ]; then
echo "no xdg config home"
echo "using ~/.config"
XDG_CONFIG_HOME=$HOME/.config
fi
if [ -z "$DEV_ENV" ]; then
echo "env var DEV_ENV needs to be present"
exit 1
fi
if [[ $1 =~ ^--dry ]]; then
dry_run="1"
fi
log() {
if [[ $dry_run == "1" ]]; then
echo "[DRY_RUN]: $1"
else
echo "$1"
fi
}
log "env: $DEV_ENV"
update_files() {
log "copying over files from: $1"
pushd $1 &>/dev/null
(
configs=$(find . -mindepth 1 -maxdepth 1 -type d)
for c in $configs; do
directory=${2%/}/${c#./}
log " removing: rm -rf $directory"
if [[ $dry_run == "0" ]]; then
rm -rf $directory
fi
log " copying env: cp $c $2"
if [[ $dry_run == "0" ]]; then
cp -r ./$c $2
fi
done
)
popd &>/dev/null
}
update_files $DEV_ENV/env/.config $XDG_CONFIG_HOME
update_files $DEV_ENV/env/.local $HOME/.local
#
# copy $DEV_ENV/tmux-sessionizer/tmux-sessionizer $HOME/.local/scripts/tmux-sessionizer
# copy $DEV_ENV/env/.zsh_profile $HOME/.zsh_profile
# copy $DEV_ENV/env/.zshrc $HOME/.zshrc
# copy $DEV_ENV/env/.xprofile $HOME/.xprofile
# copy $DEV_ENV/env/.tmux-sessionizer $HOME/.tmux-sessionizer
# copy $DEV_ENV/dev-env $HOME/.local/scripts/dev-env
#
#
# mkdir -p $HOME/.local/bin
#
hyprctl reload