-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlink.sh
More file actions
executable file
·46 lines (35 loc) · 1.31 KB
/
link.sh
File metadata and controls
executable file
·46 lines (35 loc) · 1.31 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
#!/bin/bash
set -euo pipefail
# Create links from ~/.config (and other locations) to files in this repository
# See: https://stackoverflow.com/questions/59895/how-can-i-get-the-source-directory-of-a-bash-script-from-within-the-script-itsel
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
mkdir -p ~/.config
# Symlink ~/.config/$dir all dirs in config
for src in $dir/config/*; do
pkg=$(basename "$src")
target="$HOME/.config/$pkg"
# If it's not a symlink...
if [[ ! -L "$target" ]]; then
# ...and it's a file or directory back it up first
if [[ -f "$target" ]] || [[ -d "$target" ]]; then
echo "making a backup of $target..."
backup=$HOME/.config/$pkg-dotfiles-backup-$(date +%s)
mv "$target" "$backup"
echo "backed up $target to $backup..."
fi
ln -s "$src" "$target"
echo "wrote link $target ~> $src..."
else
echo "$target already exists and is a symlink, skipping..."
fi
done
# Symlink things that don't live in ~/.config
if [[ ! -L "$HOME/.tmux.conf" ]]; then
ln -s $dir/tmux/tmux.conf "$HOME/.tmux.conf"
fi
if [[ ! -L "$HOME/.kube/kubie.yaml" ]]; then
ln -s $dir/kubie/kubie.yaml "$HOME/.kube/kubie.yaml"
fi
# Silence iTerm login message
touch ~/.hushlogin
echo "OK: link complete"