|
1
|
#!/usr/bin/env bash |
|
2
|
set -e |
|
3
|
|
|
4
|
# the path to dir where the script and dotfiles are located |
|
5
|
# set to specific path so this script can be run from anywhere |
|
6
|
dotfilesPath="$HOME/.dotfiles" |
|
7
|
|
|
8
|
h() { # ln -sf and logs path |
|
9
|
ln -sf "$1" "$2" |
|
10
|
echo "[ln] $2" |
|
11
|
} |
|
12
|
|
|
13
|
mkd() { # mkdir -p and logs path |
|
14
|
mkdir -p "$1" |
|
15
|
echo "[mkdir] $1" |
|
16
|
} |
|
17
|
|
|
18
|
create_links_in_dir_recursively() { |
|
19
|
local base_dir="$dotfilesPath/$1" |
|
20
|
local target_dir="$2" |
|
21
|
|
|
22
|
find "$base_dir/" -type d | while read -r dir; do |
|
23
|
mkd "$HOME/$target_dir${dir#"$base_dir"}" |
|
24
|
find "$dir" -maxdepth 1 -type f | while read -r file; do |
|
25
|
h "$file" "$HOME/$target_dir${file#"$base_dir"}" |
|
26
|
done |
|
27
|
done |
|
28
|
} |
|
29
|
|
|
30
|
h "$dotfilesPath/tmux.conf" "$HOME/.tmux.conf" |
|
31
|
|
|
32
|
mkd "$HOME/bin/" |
|
33
|
find "$dotfilesPath/bin" -type f -exec ln -sf {} "$HOME/bin/" \; |
|
34
|
|
|
35
|
create_links_in_dir_recursively "config" ".config" |