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