-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapply.fish
More file actions
executable file
·57 lines (48 loc) · 2.04 KB
/
apply.fish
File metadata and controls
executable file
·57 lines (48 loc) · 2.04 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
#!/usr/bin/env fish
# Greatly inspired by https://github.com/dbalatero/dotfiles/blob/main/apply
set dotfiles_dir (realpath (dirname (status --current-filename)))
function symlink -a src destination
set --function full_src_path "$dotfiles_dir/$src"
mkdir -p (dirname "$destination")
echo -n "Attempting to symlink $destination -> $full_src_path: "
if test -e "$destination" # File already exists at destination
if test -L "$destination" # Destination is a symlink
set --function existing_link (readlink "$destination")
if test "$full_src_path" = "$existing_link"
set_color green; echo "This symlink already exists, skipping!"; set_color normal
else
set_color red; echo "Symlink to \"$existing_link\" already exists at destination"; set_color normal
ln -s -i "$full_src_path" "$destination"
end
else
set_color red; echo "File already exists at destination"; set_color normal
ln -s -i "$full_src_path" "$destination"
end
else # No file exists at destination
set_color green; echo "No conflict found"; set_color normal
ln -s "$full_src_path" "$destination"
end
end
# Fish
set_color --bold; echo "# Fish"; set_color normal
symlink fish/config.fish "$HOME/.config/fish/config.fish"
for f in fish/functions/*
symlink $f "$HOME/.config/fish/functions/"(basename $f)
end
for f in fish/conf.d/*
symlink $f "$HOME/.config/fish/conf.d/"(basename $f)
end
# Git
set_color --bold; echo "# Git"; set_color normal
symlink git/config "$HOME/.config/git/config"
symlink git/config.user "$HOME/.config/git/config.user"
# Karabiner
set_color --bold; echo "# Karabiner"; set_color normal
ln -s -i "$dotfiles_dir/karabiner" ~/.config # https://karabiner-elements.pqrs.org/docs/manual/misc/configuration-file-path/
# Hammerspoon
set_color --bold; echo "# Hammerspoon"; set_color normal
for f in hammerspoon/*
symlink $f "$HOME/.hammerspoon/"(basename $f)
end
# Homebrew packages
xargs brew install < brew.txt