Last active
August 29, 2015 14:03
-
-
Save enxebre/39d9eb2e542c48dabb0c 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
| #!/bin/bash | |
| _help() { | |
| cat <<EOHELP | |
| USAGE: $0 <src folder> <dest folder>[...] | |
| Create symlinks to .file-name for every file into a given folder. | |
| OPTIONS: | |
| -h, --help Display this message and exit. | |
| EOHELP | |
| exit 0 | |
| } | |
| syserr() { | |
| echo "$0: ERROR: $*" 1>&2 | |
| exit 1 | |
| } | |
| ## No arguments | |
| if [[ ${#*} -eq 0 ]]; then | |
| _help | |
| fi | |
| case "$1" in | |
| -h|--help) _help;; | |
| esac | |
| if [ ! -d "$1" ]; then | |
| syserr "Folder not found." | |
| fi | |
| cd $1 | |
| DEST_FOLDER=${2:-../} | |
| NAME=$(git config --global --get user.name) | |
| EMAIL=$(git config --global --get user.email) | |
| unset DOT_FILES; | |
| DOT_FILES=$(ls); | |
| FILES_FOLDER=$(pwd); | |
| for file in ${DOT_FILES}; | |
| do ln -sf ${FILES_FOLDER}/${file} "${DEST_FOLDER}/.${file}" | |
| done; | |
| if [ -n "$NAME" ]; then | |
| git config --global user.name ${NAME}; | |
| fi | |
| if [ -n "$EMAIL" ]; then | |
| git config --global user.email ${EMAIL}; | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment