Skip to content

Instantly share code, notes, and snippets.

@jhonnymoreira
Last active December 24, 2016 08:41
Show Gist options
  • Save jhonnymoreira/b4497ea51844720347f08bc915bc4073 to your computer and use it in GitHub Desktop.
Save jhonnymoreira/b4497ea51844720347f08bc915bc4073 to your computer and use it in GitHub Desktop.
A study with Shell Script to rename and create dotfiles symlinks.
#!/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