This repository was archived by the owner on May 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
feat(dotfiles): add ability to apply dotfiles as any user #133
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d6b338c
feat(dotfiles): move script to run.sh
phorcys420 873f057
feat(dotfiles): add ability to provide an arbitrary dotfiles_uri
phorcys420 b8db92e
fix(dotfiles): remove non-existant `ROOT` variable from `run.sh`
phorcys420 8444934
refactor(dotfiles): move `dotfiles_uri` to local variables to avoid r…
phorcys420 e653503
feat(dotfiles): add ability to provide an arbitrary user
phorcys420 ae23a5f
fix(dotfiles): rename `coder_script` to "dotfiles" (from "personalize")
phorcys420 1d62eb7
chore(dotfiles): document the newly created `user` and `dotfiles_uri`…
phorcys420 bac5406
chore(dotfiles): clarify README to reflect that you can use any user
phorcys420 f44947f
chore(dotfiles): clarify README to reflect that root isn't the only o…
phorcys420 a2bdfef
chore(dotfiles): mention that setting the `dotfiles_uri` parameter di…
phorcys420 b27f396
fix(dotfiles): overwrite dotfiles log instead of appending
phorcys420 63c0712
fix(dotfiles): get the proper user's home directory
phorcys420 f7d9486
chore(dotfiles); fix comments in run.sh
phorcys420 6ffc79f
chore(dotfiles): clarify the script for other users
phorcys420 b9bec0f
Merge branch 'coder:main' into dotfiles-root
phorcys420 0b8fe33
fix(dotfiles): fix formatting
phorcys420 f94d0b7
Merge branch 'main' into dotfiles-root
phorcys420 808ee2b
fix(dotfiles): format & lint
phorcys420 437ea98
fix(dotfiles): fix typos
phorcys420 f92a612
chore(dotfiles): unfix typo in README to stay in the scope of the PR
phorcys420 9239a4c
Merge branch 'main' into dotfiles-root
matifali File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
DOTFILES_URI="${DOTFILES_URI}" | ||
DOTFILES_USER="${DOTFILES_USER}" | ||
|
||
if [ -n "$${DOTFILES_URI// }" ]; then | ||
if [ -z "$DOTFILES_USER" ]; then | ||
DOTFILES_USER="$USER" | ||
fi | ||
|
||
echo "✨ Applying dotfiles for user $DOTFILES_USER" | ||
|
||
if [ "$DOTFILES_USER" = "$USER" ]; then | ||
coder dotfiles "$DOTFILES_URI" -y 2>&1 | tee ~/.dotfiles.log | ||
else | ||
# The `eval echo ~"$DOTFILES_USER"` part is used to dynamically get the home directory of the user, see https://superuser.com/a/484280 | ||
# eval echo ~coder -> "/home/coder" | ||
# eval echo ~root -> "/root" | ||
|
||
CODER_BIN=$(which coder) | ||
DOTFILES_USER_HOME=$(eval echo ~"$DOTFILES_USER") | ||
sudo -u "$DOTFILES_USER" sh -c "'$CODER_BIN' dotfiles '$DOTFILES_URI' -y 2>&1 | tee '$DOTFILES_USER_HOME'/.dotfiles.log" | ||
fi | ||
fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should only have one of these