Skip to content

Instantly share code, notes, and snippets.

@miccolis
Created January 5, 2012 15:14
Show Gist options
  • Save miccolis/1565664 to your computer and use it in GitHub Desktop.
Save miccolis/1565664 to your computer and use it in GitHub Desktop.
link dotfiles into a home dir
#!/bin/sh
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
FILES=`ls -a $DIR`;
for FILENAME in $FILES; do
if [ ${FILENAME:0:1} == "." -a ${#FILENAME} -gt "2" ]; then
EXT=${FILENAME##*.}
# Ignore vi swp files.
if [ $EXT == "swp" ]; then
continue;
fi
FILEPATH="$DIR/$FILENAME";
if [ -e ~/$FILENAME ]; then
echo "> File '$FILENAME' exists, skipping.";
else
echo "> Linking '$FILENAME'";
ln -s $FILEPATH ~/$FILENAME
fi
fi;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment