-
Notifications
You must be signed in to change notification settings - Fork 1
/
sync.sh
executable file
·41 lines (33 loc) · 1 KB
/
sync.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
#!/usr/bin/env bash
set -eo pipefail
rm -rf ~/.config/nvim 2> /dev/null
rm -rf ~/.config/wezterm 2> /dev/null
rm -rf ~/.config/starship.toml 2> /dev/null
mkdir -p ~/.config/wezterm
ln -s ~/.config/home-manager/nvim ~/.config/nvim
ln -s ~/.config/home-manager/wezterm.lua ~/.config/wezterm/wezterm.lua 2> /dev/null
ln -s ~/.config/home-manager/starship.toml ~/.config/starship.toml 2> /dev/null
if ! command -v home-manager &> /dev/null; then
nix run home-manager -- init --switch
else
home-manager switch
fi
if [[ "$(uname)" == "Darwin" ]]; then
HOME_APPS="$HOME"/Applications
NIX_APPS="$HOME"/.nix-profile/Applications
# remove broken links
for f in "$HOME_APPS"/*; do
if [ -L "$f" ] && [ ! -e "$f" ]; then
rm "$f"
fi
done
# link new ones
for f in "$NIX_APPS"/*; do
app_name="$(basename "$f")"
echo "$HOME_APPS/$app_name"
if [ ! -e "$HOME_APPS/$app_name" ]; then
echo ln -s "$f" "$HOME_APPS"/
ln -s "$f" "$HOME_APPS"/
fi
done
fi