-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsymlinker.sh
More file actions
executable file
·30 lines (25 loc) · 866 Bytes
/
symlinker.sh
File metadata and controls
executable file
·30 lines (25 loc) · 866 Bytes
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
#!/bin/sh
###
# Script which symlinks the contents of it's parent folder into $HOME.
###
currentDir=$(pwd)
dest="$HOME"
if [ -n "${1+x}" ]; then
dest=$1
echo "Explicit destination $1 given."
fi
echo "Creating links from $currentDir in $dest"
for file in $(ls -a); do
# If the file is ., .., .git, this script or README then do nothing.
if echo $file | grep -Eq '^\.$|^\.\.$|^\.git$|^\.ssh$|^.+\.bash~?$|^.+\.sh~?$|^.+\.rules~?$|^.+\.conf~?$|^README$|^mailconf$|^guix$|^lightdm-session$'; then
continue
fi
if [ -e $dest/$file ]; then
echo $file already exists, moving existing to $file.old
mv $dest/$file $dest/$file.old
fi
ln -s $currentDir/$file $dest/$file
done
# Special case for .ssh since some systems (RHEL) does not allow for ~/.ssh to be a symlink.
chmod g-rw,o-r $currentDir/.ssh/config
ln $currentDir/.ssh/config $dest/.ssh/config