From 8dc02e47f3c98bcc5328d6f785d33a2de7867380 Mon Sep 17 00:00:00 2001 From: mmoreno Date: Fri, 11 Jun 2021 16:07:54 -0600 Subject: [PATCH] So that you do not have problems when using different computers with different user names --- scripts/dotfiles/create | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/dotfiles/create b/scripts/dotfiles/create index dbc35e770..500a7a549 100755 --- a/scripts/dotfiles/create +++ b/scripts/dotfiles/create @@ -5,10 +5,20 @@ set -euo pipefail source "$DOTLY_PATH/scripts/core/_main.sh" dotfiles::apply_templating() { + PRINT_PATH=$(dotfiles::separate_dotpath_if_defalut_path) if platform::is_macos; then - sed -i '' -e "s|XXX_DOTFILES_PATH_XXX|$DOTFILES_PATH|g" "$DOTFILES_PATH/shell/zsh/.zshenv" + sed -i '' -e "s|XXX_DOTFILES_PATH_XXX|$PRINT_PATH|g" "$DOTFILES_PATH/shell/zsh/.zshenv" else - sed -i -e "s|XXX_DOTFILES_PATH_XXX|$DOTFILES_PATH|g" "$DOTFILES_PATH/shell/zsh/.zshenv" + sed -i -e "s|XXX_DOTFILES_PATH_XXX|$PRINT_PATH|g" "$DOTFILES_PATH/shell/zsh/.zshenv" + fi +} + +dotfiles::separate_dotpath_if_defalut_path() { + if grep -q "^$HOME*" <<< "$DOTFILES_PATH"; then + ONLY_DOTPATH=$(echo $DOTFILES_PATH | awk -F"$HOME" '{ print $2 }') + echo '$HOME'$ONLY_DOTPATH + else + echo '$DOTFILES_PATH' fi }