-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·77 lines (69 loc) · 2.15 KB
/
install
File metadata and controls
executable file
·77 lines (69 loc) · 2.15 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
#!/usr/bin/env bash
# install all these files into the user's home folder
FORCE=0
if [ "$1" = "-f" ]; then
FORCE=1
fi
DOTFILES=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
if [ ! "$XDG_CONFIG_HOME" ]; then
echo "\$XDG_CONFIG_HOME is not set, defaulting to ~/.config"
XDG_CONFIG_HOME="$HOME/.config"
fi
# if you simply `ln` twice, ln will put a folder in a folder
# so this is a more complicated operation than just ln
checked_link() {
local src="$1"
local dest="$2"
local parent=$(dirname "$dest")
# does it need to be installed?
if [ "$FORCE" -eq 1 ] && [ -L "$dest" ]; then
unlink "$dest"
mkdir -p "$parent"
ln -isv "$src" "$dest"
elif [ ! -s "$dest" ]; then
mkdir -p "$parent"
ln -isv "$src" "$dest"
else
echo "$dest already exists, skipping"
fi
}
# just copy, each computer is different
copy_install() {
local src="$1"
local dest="$2"
# does it need to be installed?
if [ ! -f "$dest" -a ! -d "$dest" ]; then
# do we need to create the parent directory tree?
local parent=$(dirname "$dest")
if [ ! -d "$parent" ]; then
mkdir -p "$parent"
fi
if [ -f "$src" ]; then
cp "$src" "$dest"
else
cp -r "$src" "$dest"
fi
else
echo "$dest already exists, skipping"
fi
}
is_linux() {
[[ "$OSTYPE" == "linux-gnu"* ]]
}
checked_link "$DOTFILES/bin" "$HOME/bin"
checked_link "$DOTFILES/ghostty/config.ghostty" "$XDG_CONFIG_HOME/ghostty/config.ghostty"
checked_link "$DOTFILES/gitignore" "$XDG_CONFIG_HOME/git/ignore"
copy_install "$DOTFILES/gitconfig" "$XDG_CONFIG_HOME/git/config"
checked_link "$DOTFILES/kitty/kitty.conf" "$XDG_CONFIG_HOME/kitty/kitty.conf"
if [[ $(uname -a) == *bazzite* ]]; then
checked_link "$DOTFILES/kitty/ublue.conf" "$XDG_CONFIG_HOME/kitty/ublue.conf"
fi
checked_link "$DOTFILES/nvim" "$XDG_CONFIG_HOME/nvim"
checked_link "$DOTFILES/tmux" "$XDG_CONFIG_HOME/tmux"
checked_link "$DOTFILES/sqliterc" "$XDG_CONFIG_HOME/sqlite3/sqliterc"
checked_link "$DOTFILES/wezterm" "$XDG_CONFIG_HOME/wezterm"
checked_link "$DOTFILES/zshrc" "$HOME/.zshrc"
checked_link "$DOTFILES/zshrc.d" "$HOME/.zshrc.d"
if is_linux; then
checked_link "$DOTFILES/hypr" "$XDG_CONFIG_HOME/hypr"
fi