Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/Fix to mitigate bugs when you have different usernames on different computers #172

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mmorenoregalado
Copy link

@mmorenoregalado mmorenoregalado commented Jun 11, 2021

Description

Use $HOME variable when defining $DOTFILES_PATH in .zshenv file when first installing dotly to mitigate bugs when you have different usernames on different computers

Motivation

At work they gave me a mac mini already configured with a username, there I started creating dotfiles and installing dotly, recently I bought a mac for me and installing dotly, when I imported my dotfiles, the username in .zshenv was different for what it launched an error since on my computer I had a username and another at work. I solved it easily by changing in .zshenv the variable /Users/nameuser/.dotfiles for $ HOME / .dotfiles

At the beginning of the error and newbie using dotly scared me a lot XD

It's easy to fix, but I think maybe it would be good if it was added in the .zshenv file when installing if the path is the default one.

@mmorenoregalado mmorenoregalado changed the title So that you do not have problems when using different computers with … Feat/Fix to mitigate bugs when you have different usernames on different computers Jun 12, 2021
@gtrabanco
Copy link
Contributor

gtrabanco commented Jun 12, 2021

This was done in eternal pending PR #129

In the proposal was done by changing fullpath for a path with $HOME if is the same current path in dot dotbot create script as yours.

The solution is simpler by using string substitution:

sed -i -e "s|XXX_DOTFILES_PATH_XXX|$DOTFILES_PATH|g" "${DOTFILES_PATH//$HOME/\$HOME}/shell/zsh/.zshenv"

@mmorenoregalado
Copy link
Author

I understand that, but even when I do it this way, in my .zshenv file I would still write the full path that is:

export DOTFILES_PATH="/Users/username/.dotfiles"
export DOTLY_PATH="$DOTFILES_PATH/modules/dotly"
export DOTLY_THEME="codely"
export ZIM_HOME="$DOTLY_PATH/modules/zimfw"

so on my personal computer in the .zshenv file:

export DOTFILES_PATH="/Users/username/.dotfiles"

and at work or other computer:

export DOTFILES_PATH="/Users/othername/.dotfiles"

so if what you write in the .zshenv file is the $HOME variable:

export DOTFILES_PATH="$HOME/.dotfiles"

so there would no longer be a problem with the username it could be any username

@gtrabanco
Copy link
Contributor

Yes, I understand the problem. I had the same :)

sanchezcarlosjr added a commit to sanchezcarlosjr/dotly that referenced this pull request Apr 13, 2024
@mmorenoregalado proposes to maintain consistency among different nodes and sessions through CodelyTV@8dc02e4 and CodelyTV#172, which generates a side-effect for users and adds a possible code smell in the future because it introduces an if-else pattern based on a condition that users may not expect. Also it doesn't allow the user to employ other environment variables, so we apply the template engine ideas and differentiate the application of Bash expansion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants