-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
executable file
·50 lines (39 loc) · 1.16 KB
/
setup
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
#!/bin/sh
# run from root dir
SCRIPT_ROOT_DIR=$(dirname "$0")
cd "$SCRIPT_ROOT_DIR" || exit
# mkdir -p is not POSIX compliant
[ ! -d ~/.local ] && mkdir ~/.local
[ ! -d ~/.local/bin ] && mkdir ~/.local/bin
ROOT_FILES='.bashrc
.dircolors
.inputrc
.aliases
.profile'
for file in $ROOT_FILES; do
ROOT_FILE_PATH=$(readlink "${HOME}/$file")
CURRENT_FILE_PATH="${PWD}/$file"
HOME_FILE_PATH="${HOME}/$file"
if [ -L "$HOME_FILE_PATH" ] && [ "$ROOT_FILE_PATH" = "$CURRENT_FILE_PATH" ]; then
echo "$HOME_FILE_PATH already linked, skip"
continue
elif [ -e "$HOME_FILE_PATH" ]; then
mv "$HOME_FILE_PATH" "$HOME_FILE_PATH".back
echo "$HOME_FILE_PATH moved to $HOME_FILE_PATH.back"
fi
ln -sf "$CURRENT_FILE_PATH" "$HOME_FILE_PATH"
done
if [ ! -e "${HOME}/.gitconfig" ]; then
cp "${PWD}/.gitconfig" "${HOME}/.gitconfig"
fi
if [ ! -e "${HOME}/.gitattributes" ]; then
cp "${PWD}/.gitattributes" "${HOME}/.gitattributes"
fi
ln -sf "$PWD/.profile" "$HOME/.bash_profile"
[ ! -d ~/.ssh ] && mkdir ~/.ssh
[ ! -d ~/.ssh/control ] && mkdir ~/.ssh/control
ln -sf "$PWD/.ssh_config" "$HOME/.ssh/config"
for i in vim tmux lynx gh docker podman; do
cd $i && ./setup
cd -
done