Last active
December 24, 2016 08:41
-
-
Save jhonnymoreira/b4497ea51844720347f08bc915bc4073 to your computer and use it in GitHub Desktop.
A study with Shell Script to rename and create dotfiles symlinks.
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
#!/bin/bash | |
blacklisted () { | |
blacklist=('LICENSE' 'README.md' 'dotfiles.sh') | |
for ((i = 0; i < ${#blacklist[@]}; i++)) | |
do | |
if [ $1 == ${blacklist[$i]} ] | |
then | |
return 0 | |
fi | |
done | |
return 1 | |
# Explanations for 0 and 1: | |
# 1 == false | |
# 0 == true | |
# | |
# Source: http://unix.stackexchange.com/a/232423 | |
} | |
for file in * | |
do | |
if [ -f $file ] && !(blacklisted $file) | |
then | |
filename=$file | |
dot_filename=".$file" | |
file_path="`pwd`/$filename" | |
link_path="$HOME/$dot_filename" | |
ln -s $file_path $link_path | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment