-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
96 lines (82 loc) · 2.22 KB
/
Copy pathsetup
File metadata and controls
96 lines (82 loc) · 2.22 KB
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
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
# Install all dotfiles into the home directory
if [ -L "$0" ]
then
SCRIPTSETUP="$(readlink "$0")"
else
SCRIPTSETUP="$0"
fi
DOTFILESDIRREL=$(dirname $SCRIPTSETUP)
cd $DOTFILESDIRREL/..
DOTFILESDIR=$(pwd -P)
[ $(uname -s) = "Darwin" ] && export MACOS=1 && export UNIX=1
[ $(uname -s) = "Linux" ] && export LINUX=1 && export UNIX=1
uname -s | grep -q "_NT-" && export WINDOWS=1
if [ $MACOS ]
then
VSCODE="$HOME/Library/Application Support/Code/User"
elif [ $LINUX ]
then
VSCODE="$HOME/.config/Code/User"
elif [ $WINDOWS ]
then
VSCODE="$APPDATA/Code/User"
fi
for DOTFILE in *; do
HOMEFILE="$HOME/.$DOTFILE"
[ -d $DOTFILE ] && DOTFILE="$DOTFILE/"
DIRFILE="$DOTFILESDIR/$DOTFILE"
# Don't mess with Codespaces' default GPG/SSH setup.
if [ -n "$CODESPACES" ]
then
echo $DOTFILE | egrep -q '^(gnupg|ssh)/' && continue
fi
# Don't try to install documentation/script files
echo $DOTFILE | egrep -q '(^script/$|\.txt$|\.md$)' && continue
# Fixup VSCode settings path
echo $DOTFILE | grep -q 'vscode-settings' &&
HOMEFILE="$VSCODE/settings.json" &&
mkdir -p "$VSCODE"
# Remove .sh extensions
echo $DOTFILE | grep -q '\.sh' &&
HOMEFILE="$HOME/.$(echo $DOTFILE | sed -e 's/\.sh//')"
# Fixup RuboCop configuration (if possible)
if echo $DOTFILE | grep -q 'rubocop-github.yml'
then
HOMEGITHUB="$HOME/GitHub"
[ -d $HOMEGITHUB ] || continue
HOMEFILE="$HOMEGITHUB/.rubocop.yml"
elif echo $DOTFILE | grep -q 'rubocop-oss.yml'
then
HOMEOSS="$HOME/OSS"
[ -d $HOMEOSS ] || continue
HOMEFILE="$HOMEOSS/.rubocop.yml"
fi
if [ $UNIX ]
then
if [ -L "$HOMEFILE" ] && ! [ -d $DOTFILE ]
then
ln -sfv "$DIRFILE" "$HOMEFILE"
else
rm -rv "$HOMEFILE" 2>/dev/null
ln -sv "$DIRFILE" "$HOMEFILE"
fi
else
cp -rv "$DIRFILE" "$HOMEFILE"
fi
done
HOMEDOTFILES="$HOME/.dotfiles"
if [ "$DOTFILESDIR" != "$HOMEDOTFILES" ]
then
ln -sf "$DOTFILESDIR" "$HOMEDOTFILES"
fi
if [ -n "$CODESPACES" ]
then
# Fix up Codespaces permissions
chmod 700 /workspaces
# Don't try to git gc github/github, it happens often and takes ages
if [ "$CODESPACE_VSCODE_FOLDER" = "/workspaces/github" ]
then
git -C /workspaces/github config gc.auto 0
fi
fi