Created
August 19, 2015 03:40
-
-
Save brandonbloom/200cb1082424ddccfad6 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
function link_all() { | |
local from=$1 | |
local to=$2 | |
for source in $(ls -d -1 $PWD/$from/*); do | |
local destination="$to$(basename $source)" | |
local current=$(readlink $destination) | |
if [ "$current" = "$source" ]; then | |
echo "Already $destination -> $source" | |
else | |
if [ "$current" ]; then | |
echo "Previously $current" | |
fi | |
echo "Linking $destination -> $source" | |
ln -s -i $source $destination | |
fi | |
done | |
} | |
link_all home "$HOME/." | |
link_all ssh "$HOME/.ssh/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment