Created
November 11, 2014 00:07
-
-
Save michaelavila/25f15a8a39b3372979b9 to your computer and use it in GitHub Desktop.
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
# usage: find-dotfiles [directory] | |
function find-dotfiles() { | |
# I store my dotfiles in git, therefore I want to ignore | |
# the following files, and everyone wants to ignore "." | |
default_excludes=("." "*.git" "*.gitmodules") | |
exclude=$(printf " -not -iwholename '%s'" ${default_excludes[*]}) # map to -not -iwholename $FILE | |
eval "find ${1-$PWD} -name '.*' $exclude -maxdepth 1 | xargs -L1 -I {} basename {}" | |
} | |
# usage: link-dotfiles [from] [to] | |
function link-dotfiles() { | |
find-dotfiles ${1-$PWD} | xargs -L1 -I {} ln -s ${1-$PWD}/{} ${2-$HOME}/{} | |
} | |
# usage: unlink-dotfiles [from] [source] | |
function unlink-dotfiles() { | |
find-dotfiles ${2-$PWD} | xargs -L1 -I {} rm -rf /tmp/d && mv ${1-$HOME}/{} /tmp/d/{} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment