-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkup
executable file
·40 lines (33 loc) · 943 Bytes
/
linkup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
set -e
function linkup
{
local src=$1
local dest=$2
local prefix=$3
find "${src}" -type f -not -name ".*" -printf "%P\n" -or -name ".gitkeep" -printf "%P\n" | while read file; do
newfile="${dest}/${prefix}${file}"
echo -n "Linking ${file} to ${newfile}..."
mkdir -p $(dirname ${newfile})
[ "$(basename ${file})" != ".gitkeep" ] && ln -sf "${src}/${file}" "${newfile}"
echo "Done."
done
}
echo "This script will clobber your profile"
echo "Setting up links over known dotfiles"
echo "and adding a local script directory"
read -r -p "Are you sure you want to continue [y/N] " response
pushd $(dirname $0) > /dev/null
script_dir=$(pwd)
popd > /dev/null
case "${response}" in
[yY][eE][sS]|[yY])
echo "Linking dotfiles"
linkup "${script_dir}/dotfiles" "${HOME}" "."
echo "Linking scripts"
linkup "${script_dir}/scripts" "${HOME}/bin"
;;
*)
echo "Aborting..."
;;
esac