summaryrefslogtreecommitdiff
path: root/link.sh
blob: 72148453245ee3fb7336ed4ba91e18a1e4476578 (plain)
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
#!/bin/bash 

# Absolute path to this script, e.g. /home/user/bin/foo.sh
SCRIPT=$(readlink -f "$0")
# Absolute path this script is in, thus /home/user/bin
HERE=$(dirname "$SCRIPT")

function link-file(){
  src=$1
  dst=$2
  # if there is a normal file there, remove it
  if [ -f "src" ]
  then 
    rm $src
  fi
  # ensure destination directory exists 
  mkdir -p $(dirname "$dst")
  # link
  ln -sf "$1" "$2"
  echo $dst "linked to" $src
}

# bash
link-file $HERE/bash/bashrc.sync ~/.bashrc.sync

# direnv
link-file $HERE/direnv/direnvrc ~/.config/direnv/direnvrc

# dunst
link-file $HERE/dunst/dunstrc ~/.config/dunst/dunstrc

# emacs
link-file $HERE/emacs/init.el ~/.emacs.d/init.el

# git
link-file $HERE/git/gitconfig ~/.gitconfig

# i3
link-file $HERE/i3/config ~/.config/i3/config

# ssh
link-file $HERE/ssh/config ~/.ssh/config

# x
link-file $HERE/x/Xresources ~/.Xresources