this repo has no description
1#!/usr/bin/env bash
2
3set -euo pipefail
4
5DOTFILES_DIR="$HOME/dotfiles"
6
7function link_configs {
8 echo "Linking configuration files..."
9
10 declare -A mappings
11
12 # TODO: Make this linux compatible
13 mappings["ghostty"]="$HOME/Library/Application Support/com.mitchellh.ghostty"
14 mappings["zsh/zshenv"]="$HOME/.zshenv"
15 mappings["zsh/zshrc"]="$HOME/.zshrc"
16 mappings["misc/tmux.conf"]="$HOME/.tmux.conf"
17 mappings["git/gitconfig"]="$HOME/.gitconfig"
18 mappings["git/gitignore"]="$HOME/.gitignore"
19 mappings["misc/vimrc"]="$HOME/.vimrc"
20 mappings["nvim"]="$HOME/.config/nvim"
21 mappings["ai/skills"]="$HOME/.claude/skills"
22 mappings["hammerspoon"]="$HOME/.hammerspoon"
23 mappings["zsh/starship.toml"]="$HOME/.config/starship.toml"
24 mappings["mise"]="$HOME/.config/mise"
25
26 for key in "${!mappings[@]}"; do
27 source="${key}"
28 destination="${mappings[$key]}"
29
30 if [ -d "$source" ]; then
31 mkdir -p "$(dirname "$destination")"
32 create_symlink "$source" "$destination"
33 elif [ -f "$source" ]; then
34 create_symlink "$source" "$destination"
35 else
36 echo "Warning: Source $source does not exist, skipping."
37 fi
38 done
39}
40
41function create_symlink {
42 local source="$1"
43 local destination="$2"
44
45 echo "$source -> $destination"
46
47 if [ -L "$destination" ]; then
48 if [ "$(readlink "$destination")" = "$DOTFILES_DIR/$source" ]; then
49 echo " Already established"
50 return
51 else
52 echo " Removing existing symlink ($(readlink "$destination"))"
53 rm "$destination"
54 fi
55 fi
56
57 if [ -e "$destination" ]; then
58 echo " Destination exists, backing it up"
59 mv "$destination" "${destination}.bak"
60 fi
61
62 echo " Creating symlink"
63 ln -s "$DOTFILES_DIR/$source" "$destination"
64}
65
66function install_tpm {
67 if [ -d "$HOME/.tmux/plugins/tpm" ]; then
68 echo "TPM is already installed."
69 return
70 fi
71 git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
72}
73
74link_configs
75install_tpm