diff --git a/copy.sh b/copy.sh index 5505217..bc21e94 100755 --- a/copy.sh +++ b/copy.sh @@ -38,9 +38,16 @@ echo "$dotfiles" | while read -r dotfile; do done function add-export { - if ! grep "$1" "$HOME/.zsh_local" &> /dev/null; then - echo "$1\"$2\"" >> "$HOME/.zsh_local" + local final="$1\"$2\"" + if grep "$final" "$HOME/.zsh_local" &> /dev/null; then + return fi + if grep "$1" "$HOME/.zsh_local" &> /dev/null; then + echo "Replacing '$(grep "$1" "$HOME/.zsh_local")' with '$final'" + local escaped="$(echo "$1" | sed 's@/@\\/@g')" + sed -i "/$escaped/d" "$HOME/.zsh_local" + fi + echo "$final" >> "$HOME/.zsh_local" } add-export "export DOT_DIR=" "$SCRIPT_DIR"