Skip to content

Commit

Permalink
Write a function to properly handle the common case of symlinking in …
Browse files Browse the repository at this point in the history
…a sourcefile from a host source.

I originally moved these files around, but I think symlinking them in is better: they tell the user that the copies they're using were created by curl-bashenv.
  • Loading branch information
preed committed Jul 12, 2015
1 parent 23a6231 commit 9aa80c1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions curl-bashenv
Expand Up @@ -90,6 +90,13 @@ function symlink_gitrepo_file() {
$LN -s "$source_file" "$dest_file"
}

function symlink_sourcehost_file() {
test -z "$1" && assert "symlink_sourcehost_file: first arg empty"
source_file="${SETUP_DIR}/$1"
dest_file="$HOME/$1"
test -e "$dest_file" && $MV "$dest_file" "${BACKUP_DIR}"
$LN -s "$source_file" "$dest_file"
}

function setup_sourcehost_ssh() {
local sshBackupDir="${BACKUP_DIR}/.ssh"
Expand Down Expand Up @@ -204,18 +211,15 @@ function setup_sourcehost_shdotfiles() {
$SCP $SOURCE:~/{$dotfile_list} ${SETUP_DIR}/

for f in $prefixed_dotfiles; do
for f in $dotfile_list; do
test -e $HOME/$f && $MV $HOME/$f ${BACKUP_DIR}
$MV ${SETUP_DIR}/$f $HOME
symlink_sourcehost_file $f
done

return 0
}

function setup_sourcehost_gitconfig() {
$SCP ${SOURCE}:~/.gitconfig ${SETUP_DIR}/
test -f $HOME/.gitconfig && $MV $HOME/.gitconfig ${BACKUP_DIR}
$MV ${SETUP_DIR}/.gitconfig $HOME
symlink_sourcehost_file .gitconfig
}

function setup_gitrepo_gitconfig() {
Expand Down

0 comments on commit 9aa80c1

Please sign in to comment.