-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·54 lines (50 loc) · 1.63 KB
/
install.sh
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
#! /usr/bin/env bash
set -eu
this_file="$(type -p "${BASH_SOURCE[0]}")"
if ! [ -e "$this_file" ] ; then
echo "Failed to resolve file."
exit 1
fi
if ! [[ "$this_file" =~ ^/ ]] ; then
this_file="$(pwd)/$this_file"
fi
while [ -h "$this_file" ] ; do
ls_res="$(ls -ld "$this_file")"
link_target=$(expr "$ls_res" : '.*-> \(.*\)$')
if [[ "$link_target" =~ ^/ ]] ; then
this_file="$link_target"
else
this_file="$(dirname "$this_file")/$link_target"
fi
done
this_dir="$(dirname "$this_file")"
install_file ()
{
local from_file=$1;
if ! [[ "$from_file" =~ ^/ ]]; then
from_file="$(pwd)/$from_file";
fi;
local to_file=$2;
mkdir -p "$(dirname "$to_file")";
backup_file "$to_file";
if ! ln -s "$from_file" "$to_file"; then
echo "Failed to create symbolic link from $from_file to ${to_file}: maybe parent dir not exist or no permission to do so";
fi
}
install_file "${this_dir}/gitconfig" "$HOME/.gitconfig"
install_file "${this_dir}/.vimrc" "$HOME/.vimrc"
install_file "${this_dir}/.xvimrc" "$HOME/.xvimrc"
install_file "${this_dir}/.bashrc" "$HOME/.bashrc"
install_file "${this_dir}/.bash_profile" "$HOME/.bash_profile"
install_file "${this_dir}/tigrc" "$HOME/.tigrc"
install_file "${this_dir}/ssh/config" "$HOME/.ssh/config"
install_file "${this_dir}/efm-langserver_config.yaml" "$HOME/.config/efm-langserver/config.yaml"
install_file "${this_dir}/npmrc-taobao" "$HOME/.npmrc"
# export -f install_file
# "${this_dir}/bin/xcode_snippets_restore" 2>/dev/null | {
# IFS_="$IFS"
# export IFS=""
# while read -r -a ll ; do
# IFS="$IFS_" install_file "${ll[@]}"
# done
# }