Skip to content

Loading…

Add ability to use symlink. #301

Open
wants to merge 2 commits into from

5 participants

@johnmetta

Might not be desired, but I don't want to copy the dotfiles, I want to link them. This was mainly a hack for me and a bunch of friends who like this repo, but want to link instead of copy.

Issue: Kills the --force full name flag because I don't flesh out the getopts call.

@kevinSuttle

@johnmetta Yep. I ran into the same thing. That's why I started this: https://github.com/kevinSuttle/OSXDefaults

See context: #300

@paulirish

This looks attractive to me. Are other folks symlinking their dotfiles as such?

I'd really like to get my git config --global commands back in automatically. And this would just make maintenance a touch easier.

cc @callumlocke

@paulirish

From @mathiasbynens in #9 (comment) :

@gburtini Actually, using symlinks was the first thing that I tried. I ended up with “recursion too deep” errors though, even though they were simple ~/.foo → ~/dotfiles/.foo links. Any idea of what I was doing wrong?

@paulirish

@alrra has some sweet symlinking up in https://github.com/alrra/dotfiles/blob/master/lib/dotfiles

looks great.

@paulirish paulirish referenced this pull request in paulirish/dotfiles
Closed

Symlinks? #30

@johnmetta johnmetta closed this
@paulirish

@johnmetta not sure why you're closing this. I think it should remain open as symlinking has huge advantages.
Unless you've changed your mind?

@webpro

Just saying: I'm symlinking with an install script and .bash_profile sourcing stuff. Works like a charm (just clean installed Yosemite)

@mathiasbynens mathiasbynens reopened this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 5, 2013
  1. @johnmetta
  2. @johnmetta

    Update readme

    johnmetta committed
Showing with 42 additions and 4 deletions.
  1. +10 −0 README.md
  2. +32 −4 bootstrap.sh
View
10 README.md
@@ -42,6 +42,16 @@ Here’s an example `~/.path` file that adds `~/utils` to the `$PATH`:
export PATH="$HOME/utils:$PATH"
```
+### Link instead of copy files
+
+```$ bootstrap -l```
+
+or using ```source```
+
+```bash
+set -- -l; source bootstrap.sh
+```
+
### Add custom commands without creating a new fork
If `~/.extra` exists, it will be sourced along with the other files. You can use this to add a few custom commands without the need to fork this entire repository, or to add commands you don’t want to commit to a public repository.
View
36 bootstrap.sh
@@ -1,18 +1,46 @@
#!/usr/bin/env bash
+OPTIND=1
+
cd "$(dirname "${BASH_SOURCE}")"
git pull origin master
function doIt() {
rsync --exclude ".git/" --exclude ".DS_Store" --exclude "bootstrap.sh" \
--exclude "README.md" --exclude "LICENSE-MIT.txt" -av --no-perms . ~
- source ~/.bash_profile
}
-if [ "$1" == "--force" -o "$1" == "-f" ]; then
- doIt
+function linkIt() {
+ FILES=$(find . -type f -maxdepth 1 -name ".*" -not -name .DS_Store -not -name .git -not -name .osx | sed -e 's|//|/|' | sed -e 's|./.|.|')
+ for file in $FILES; do
+ ln -sf $(dirname "${BASH_SOURCE}")/${file} ~/${file}
+ done
+}
+
+while getopts "fl" opt; do
+ case "$opt" in
+ f)
+ FORCE=1
+ ;;
+ l)
+ LINK=1
+ ;;
+ esac
+done
+
+if [ "$FORCE" == "1" ]; then
+ if [ "$LINK" == "1" ]; then
+ linkIt
+ else
+ doIt
+ fi
else
read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
- doIt
+ if [ "$LINK" == "1" ]; then
+ linkIt
+ else
+ doIt
+ fi
fi
fi
+source ~/.bash_profile
unset doIt
Something went wrong with that request. Please try again.