Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·91 lines (83 loc) · 3.55 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·91 lines (83 loc) · 3.55 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
#!/usr/bin/env bash
################################################################################
# files to symlink for both Linux and Mac environments
################################################################################
declare -A filesToSymlink
filesToSymlink=(
["nvim"]="$HOME/.config/nvim"
[".bashrc"]="$HOME/.bashrc"
["tmux.conf"]="$HOME/.config/tmux/tmux.conf"
[".tigrc"]="$HOME/.tigrc"
["zellij_config.kdl"]="$HOME/.config/zellij/config.kdl"
["zellij_layout.kdl"]="$HOME/.config/zellij/layouts/default.kdl"
["zellij_kube_context.sh"]="$HOME/.config/zellij/kube-context.sh"
["k9s"]="$HOME/.config/k9s"
# [".claude/settings.json"]="$HOME/.claude/settings.json" # ignored, because it has some machine-specific values
[".claude/keybindings.json"]="$HOME/.claude/keybindings.json"
[".claude/scripts"]="$HOME/.claude/scripts"
[".claude/CLAUDE.md"]="$HOME/.claude/CLAUDE.md"
[".claude/skills"]="$HOME/.claude/skills"
)
################################################################################
# files to symlink for on MacOS only
################################################################################
if [[ "$OSTYPE" == darwin* ]]; then
filesToSymlink["ghostty"]="$HOME/.config/ghostty"
filesToSymlink[".ideavimrc"]="$HOME/.ideavimrc"
filesToSymlink["aerospace"]="$HOME/.config/aerospace"
fi
if [[ $EUID -eq 0 ]]; then
echo "[ERR] You cannot run this script as root"
exit 1
fi
dotfiles_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo "[INFO] Symlinking dotfiles ..."
for file in "${!filesToSymlink[@]}"
do
echo " -> linking $file"
target_path="${filesToSymlink[$file]}"
origin_path="$dotfiles_dir/$file"
mkdir -p "$(dirname "$target_path")"
[[ -e "$target_path" || -L "$target_path" ]] && rm -rf "$target_path"
ln -s "$origin_path" "$target_path"
done
################################################################################
# download the zjstatus zellij plugin if missing
################################################################################
zjstatus_version="v0.25.0"
zjstatus_path="$HOME/.config/zellij/plugins/zjstatus.wasm"
if [[ ! -f "$zjstatus_path" ]]; then
echo "[INFO] Downloading zjstatus $zjstatus_version ..."
mkdir -p "$(dirname "$zjstatus_path")"
# -f fail on http error, -L follow redirects, -o write to file
curl -fL -o "$zjstatus_path" \
"https://github.com/dj95/zjstatus/releases/download/$zjstatus_version/zjstatus.wasm"
fi
################################################################################
# pre-grant zellij plugin permissions for zjstatus
# without this, zjstatus renders a blank bar until you focus its pane and press
# 'y', and a pending permission prompt can freeze the session on exit
################################################################################
if [[ "$OSTYPE" == darwin* ]]; then
zellij_cache_dir="$HOME/Library/Caches/org.Zellij-Contributors.Zellij"
else
zellij_cache_dir="$HOME/.cache/zellij"
fi
zellij_perms="$zellij_cache_dir/permissions.kdl"
# the permission key is the bare wasm path (RunPluginLocation::File Display),
# not the "file:" location string
zjstatus_key="$zjstatus_path"
# only write if this plugin key is not already granted, so we don't clobber
# permissions granted for other plugins
if [[ ! -f "$zellij_perms" ]] || ! grep -qF "$zjstatus_key" "$zellij_perms"; then
echo "[INFO] Granting zjstatus plugin permissions ..."
mkdir -p "$zellij_cache_dir"
cat >> "$zellij_perms" <<EOF
"$zjstatus_key" {
ReadApplicationState
ChangeApplicationState
RunCommands
}
EOF
fi
echo "[INFO] Done."