-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·86 lines (68 loc) · 1.92 KB
/
configure
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
SOURCEDIR=''
PROFILECONFIGDIR=${PROFILECONFIGDIR:-"$HOME/.profileconfig"}
# SOURCEDIR="$HOME/.personalshare"
if [[ "$SOURCEDIR" == "" ]]; then
SOURCEDIR=$PWD
fi
### Make the personal share folder
if [[ ! -d "$SOURCEDIR" ]]; then
make-symlink "$PWD" "$SOURCEDIR"
fi
MACHINECONFIGDIR="$SOURCEDIR/machine-configs/$HOSTNAME"
function link-profile-file() {
local file=$1
make-symlink "$PROFILECONFIGDIR/$file" "$HOME/.$file"
}
function setup-source-file() {
local file=$1
make-symlink "$SOURCEDIR/$file" "$MACHINECONFIGDIR/$file"
}
function setup-profile-file() {
local file=$1
setup-source-file "$file"
link-profile-file "$file"
}
function make-symlink() {
local source=$1
local target=$2
if [[ -f "$target" ]] || [[ -d "$target" ]] || [[ -h "$target" ]]; then
# if [[ -e "$target" ]]; then ## -e seems to not cooperate with all symlinks...
if [[ -h "$target" ]] && [[ $(readlink -n "$target") != $source ]]; then
echo Updating symlink: \""$source"\" \""$target"\"
# echo source: "$(realpath \"$source\")"
# echo target: "$(realpath \"$target\")"
ln -sf "$source" "$target"
else
# echo $source
# echo $target
# echo This two are the same
# echo " $(realpath $source)"
# echo " $(readlink $source)"
# echo " $(realpath $target)"
# echo " $(readlink $target)"
# if [[ $(readlink -n "$target") == $source ]]; then
# echo "Target points to source already!"
# else
# echo "target points to some other place"
# fi
echo " No need to create $source"
fi
else
echo Making symlink: \""$source"\" \""$target"\"
ln -s "$source" "$target"
fi
}
### machine-specific config folder
make-symlink "$SOURCEDIR" "$PROFILECONFIGDIR"
### Bash Profile
link-profile-file bash_profile
link-profile-file bashrc
link-profile-file zshenv
link-profile-file zprofile
link-profile-file zshrc
### screen cfg
link-profile-file screenrc
### X11 cfg
link-profile-file Xresources
echo Done.