Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·176 lines (130 loc) · 5.23 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·176 lines (130 loc) · 5.23 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/bash
usage() {
echo "usage: $0 [<bash|fish|vim|git>...]"
}
if [[ $# -gt 0 ]] && [[ "$1" = '-h' ]]; then
usage
exit 0
fi
do_all=false
if [[ $# -eq 0 ]]; then
do_all=true
fi
do_bash=false
do_fish=false
do_scripts=false
do_prompts=false
do_colours=false
do_vim=false
do_git=false
while [[ $# -gt 0 ]]; do
case "$1" in
bash) do_bash=true; do_scripts=true; do_colours=true; do_prompts=true;;
fish) do_fish=true; do_scripts=true; do_colours=true;;
git) do_git=true;;
vim) do_vim=true;;
*) usage; exit 1;;
esac
shift
done
this_dir=$(dirname "$(realpath "$0")")
install_file() {
# usage: install_file <source> <destination>
echo "INSTALL $1 -> $2"
if [[ -O "$1" ]]; then
[[ -f "$2" ]] && rm "$2"
ln "$1" "$2"
else
cp "$1" "$2"
fi
}
if [[ "$do_bash" = true ]] || [[ "$do_all" = true ]]; then
echo " ===== Bash =========================="
bash_config_dir="${HOME}/.config/bash"
[[ -d "$bash_config_dir" ]] || mkdir "$bash_config_dir"
install_file "${this_dir}/shell/bash/profile.sh" ~/.profile
install_file "${this_dir}/shell/bash/bashrc.sh" ~/.bashrc
install_file "${this_dir}/shell/bash/bash_variables.sh" "${bash_config_dir}/variables"
install_file "${this_dir}/shell/bash/bash_aliases.sh" "${bash_config_dir}/aliases"
install_file "${this_dir}/shell/bash/bash_prompt.sh" "${bash_config_dir}/prompt"
fi
if [[ "$do_fish" = true ]] || [[ "$do_all" = true ]]; then
echo " ===== Fish =========================="
fish_config_dir="${HOME}/.config/fish"
fish_functions_dir="${fish_config_dir}/functions"
mkdir -p "$fish_functions_dir"
install_file "${this_dir}/shell/fish/config.fish" "${fish_config_dir}/config.fish"
install_file "${this_dir}/shell/fish/variables.fish" "${fish_config_dir}/variables.fish"
install_file "${this_dir}/shell/fish/aliases.fish" "${fish_config_dir}/aliases.fish"
install_file "${this_dir}/shell/fish/functions/fish_prompt.fish" "${fish_functions_dir}/fish_prompt.fish"
install_file "${this_dir}/shell/fish/functions/fish_greeting.fish" "${fish_functions_dir}/fish_greeting.fish"
fi
if [[ "$do_scripts" = true ]] || [[ "$do_all" = true ]]; then
echo " ===== Scripts =========================="
scripts_exec_dir="${HOME}/.local/bin"
mkdir -p "$scripts_exec_dir"
while IFS= read -r script_file; do
filename="$(basename "$script_file")"
filename="${filename%.*}"
install_file "$script_file" "${scripts_exec_dir}/${filename}"
done < <(find "${this_dir}/shell/scripts" -executable -type f)
fi
if [[ "$do_prompts" = true ]] || [[ "$do_all" = true ]]; then
echo " ===== Prompts =========================="
starship_conf_dir="${HOME}/.config/starship"
mkdir -p "$starship_conf_dir"
while IFS= read -r prompt_file; do
filename="$(basename "$prompt_file")"
install_file "$prompt_file" "${starship_conf_dir}/${filename}"
done < <(find "${this_dir}/terminal/starship" -type f -name '*.toml')
fi
if [[ "$do_colours" = true ]] || [[ "$do_all" = true ]]; then
echo " ===== Colours =========================="
colours_script="${this_dir}/shell/colours/colour_variables.py"
colours_conf_dir="${HOME}/.config/custom_colours"
mkdir -p "$colours_conf_dir"
generate_colour_profile() { # generate_colour_profile <classes> <colours> <out_file>
echo "GENERATE ${3}.sh"
"${colours_script}" bash "$1" "$2" > "${3}.sh"
echo "GENERATE ${3}.fish"
"${colours_script}" fish "$1" "$2" > "${3}.fish"
}
while IFS= read -r profile_dir; do
profile_name="$(basename "$profile_dir")"
classes_file="${profile_dir}/ls_classes.yaml"
colours_file="${profile_dir}/colours.yaml"
if [[ -f "$classes_file" ]] && [[ -f "$colours_file" ]]; then
generate_colour_profile "$classes_file" "$colours_file" "${colours_conf_dir}/${profile_name}"
fi
done < <(find "${this_dir}/shell/colours" -type d)
fi
if [[ "$do_git" = true ]] || [[ "$do_all" = true ]]; then
echo " ===== Git =========================="
git_config_dir='.config/git'
git_scripts_dir='.local/share/git'
[[ -d ~/"$git_config_dir" ]] || mkdir ~/"$git_config_dir"
mkdir -p ~/"$git_scripts_dir"
git_config_file="${git_config_dir}/config"
if ! git config --global --get-all include.path | grep '^'"~/$git_config_file"'$' > /dev/null; then
git config --global --add include.path "~/$git_config_file"
fi
install_file "${this_dir}/command-line/git/config" ~/"$git_config_file"
for file in "${this_dir}/command-line/git/scripts"/*.sh; do
install_file "${file}" ~/"$git_scripts_dir/$(basename "$file")"
done
fi
if [[ "$do_vim" = true ]] || [[ "$do_all" = true ]]; then
echo " ===== Vim =========================="
vim_config_dir="${HOME}/.vim"
[[ -d "$vim_config_dir" ]] || mkdir "$vim_config_dir"
install_file "${this_dir}/command-line/vim/vimrc" ~/.vimrc
install_file "${this_dir}/command-line/vim/options.vim" "${vim_config_dir}/options.vim"
install_file "${this_dir}/command-line/vim/commands.vim" "${vim_config_dir}/commands.vim"
install_file "${this_dir}/command-line/vim/mappings.vim" "${vim_config_dir}/mappings.vim"
install_file "${this_dir}/command-line/vim/filetypes.vim" "${vim_config_dir}/filetypes.vim"
vim_filetypes_dir="${vim_config_dir}/ftplugin"
[[ -d "$vim_filetypes_dir" ]] || mkdir "$vim_filetypes_dir"
for file in "${this_dir}/command-line/vim/ftplugin"/*.vim; do
install_file "${file}" "${vim_filetypes_dir}/$(basename "$file")"
done
fi