summaryrefslogtreecommitdiff
path: root/script/setup
blob: 49ac955a5533761c9b67aa6245cf11a3baff042b (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash

set -e

cd "$(dirname "$0")/.."

function dotdir()
{
  dir=$1
  source="$PWD/$dir"
  destination="$HOME/.$dir"
  chmod 700 "$source"
  ln -sfn "$source" "$destination"
}

function dotfile()
{
  file=$1
  source=$PWD/$file
  destination=$HOME/.$file
  parent_dir="$(dirname "$destination")"
  mkdir -p "$parent_dir"
  echo "linking $source to $destination"
  chmod 700 "$(dirname "$source")"
  if [ "$(basename "$parent_dir")" == 'bin' ]; then
    chmod 700 "$source"
  else
    chmod 600 "$source"
  fi
  ln -sfn "$source" "$destination"
}

function try()
{
  "$@" 2>/dev/null || sudo "$@"
}

mkdir -p "$HOME/.config" "$HOME/.local/bin" "$HOME/.local/share"
git submodule update --init

dotdir "vim"
dotfile "ackrc"
dotfile "agignore"
dotfile "bashrc"
dotfile "config/nvim/init.vim"
dotfile "ctags"
dotfile "curlrc"
dotfile "editrc"
dotfile "gitconfig"
dotfile "gitignore_global"
dotfile "inputrc"
dotfile "npmrc"
dotfile "profile"
dotfile "ssh/config"
dotfile "tmux.conf"
dotfile "vimrc"
dotfile "wgetrc"

try apt-get update -y
# shellcheck disable=SC2046
try apt-get install -y --no-install-recommends $(tr '\n' ' ' < ./apt.list)

command -v fd || try ln -s /usr/bin/fdfind /usr/bin/fd