-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·155 lines (121 loc) · 3.14 KB
/
install.sh
File metadata and controls
executable file
·155 lines (121 loc) · 3.14 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/sh
# Set some variables:
LINE='--------------------------------------------------------------'
CURR_DIR=`basename $PWD`
VIM_VENDOR='~/vim/pack/vendor'
# Ensure we call this script from the proper place:
if [ $CURR_DIR != 'dotfiles' ]; then
echo $LINE
echo " ERROR!"
echo " You MUST execute this script from within the dotfiles directory, like this:"
echo " $ ./install.sh"
echo $LINE
exit 1
fi
_symlink() {
local from=$1
local to=$2
# Do the actual command:
ln -s $from $to
}
# Error out if {something}:
_err_if_file_doesnt_exist() {
local f=$1
if [ ! -f "$f" ]; then
echo "❌ ERROR: $f does not exist."
exit 1
fi
}
_err_if_dir_doesnt_exist() {
local d=$1
if [ ! -d "$d" ]; then
echo "❌ ERROR: $d does not exist."
exit 1
fi
}
_err_if_file_already_exists() {
local f=$1
if [ -f "$f" ]; then
echo "❌ ERROR: $f already exists."
exit 1
fi
}
_err_if_dir_already_exists() {
local d=$1
if [ -d "$d" ]; then
echo "❌ ERROR: $d already exists."
fi
}
_err_if_source_already_exists() {
local line=$1
local file=$2
local basenamed=$(basename $line)
if grep -Fq "$basenamed" $file
then
echo "❌ ERROR: The line '$line' already exist in $file."
exit 1
fi
}
# Installation scripts:
_install() {
local from=$1
local to=$2
echo "Installing $from..."
if [ -L "$to" ]; then
echo "❌ Symlink to $to already exists. Skipping..."
return
fi
_err_if_file_doesnt_exist $from
#_err_if_file_already_exists $to
err=$(_err_if_file_already_exists $to)
if [ -n "$err" ]; then
echo "❌ Symlink to $to already exists. Skipping..."
else
echo "Installing '$from' to '$to'..."
_symlink $from $to
fi
}
_install_bash_source() {
local src=$1
local file=$2
echo "Installing a sourcing of '$src' to '$file'..."
_err_if_source_already_exists $src $file
echo "source $src" >> $file
}
_install_dir() {
local from=$1
local to=$2
echo "Installing $from directory..."
if [ -L "$to" ]; then
echo "❌ Symlink to $to already exists. Skipping..."
return
fi
_err_if_dir_doesnt_exist $from
err=$(_err_if_dir_already_exists $to)
if [ -n "$err" ]; then
echo "❌ Folder to $to already exists. Skipping..."
else
echo "Installing '$from' directory to '$to'..."
_symlink $from $to
fi
}
# Run the installation of dot(files|directories) ...
_install_dir $PWD/dot_config $HOME/.config
_install $PWD/tmux.conf $HOME/.tmux.conf
_install $PWD/gitconfig $HOME/.gitconfig
_install $PWD/vimrc $HOME/.vimrc
_install $PWD/bashrc $HOME/.bashrc
_install $PWD/ssh_rc.sh $HOME/.ssh/rc
#_install $PWD/xprofile $HOME/.xprofile
#_install $PWD/xinitrc $HOME/.xinitrc
_install $PWD/inputrc $HOME/.inputrc
_install_dir $PWD/vim $HOME/.vim
#_install_dir $PWD/screenlayout $HOME/.screenlayout
# Adding bash sub-config:
_install_bash_source $PWD/bash_aliases.sh $HOME/.bashrc
git clone git@github.com:juliend2/neovim-configs.git $HOME/.config/nvim
# Add plugins' documentation:
vim -u NONE -c "helptags $VIM_VENDOR/start/nerdtree/doc" -c q
echo "+-----------------------------------------------------+"
echo "| NOTE: For the .ssh/config, look at Bitwarden |"
echo "+-----------------------------------------------------+"