main
 1#!/bin/bash
 2
 3set -e
 4
 5cd "$(dirname "$0")/.."
 6
 7function dotdir()
 8{
 9  dir=$1
10  source="$PWD/$dir"
11  destination="$HOME/.$dir"
12  chmod 700 "$source"
13  ln -sfn "$source" "$destination"
14}
15
16function dotfile()
17{
18  file=$1
19  source=$PWD/$file
20  destination=$HOME/.$file
21  parent_dir="$(dirname "$destination")"
22  mkdir -p "$parent_dir"
23  echo "linking $source to $destination"
24  chmod 700 "$(dirname "$source")"
25  if [ "$(basename "$parent_dir")" == 'bin' ]; then
26    chmod 700 "$source"
27  else
28    chmod 600 "$source"
29  fi
30  ln -sfn "$source" "$destination"
31}
32
33function try()
34{
35  "$@" 2>/dev/null || sudo "$@"
36}
37
38mkdir -p "$HOME/.config" "$HOME/.local/bin" "$HOME/.local/share"
39git submodule update --init
40
41dotdir "vim"
42dotfile "ackrc"
43dotfile "agignore"
44dotfile "bashrc"
45dotfile "config/nvim/init.vim"
46dotfile "ctags"
47dotfile "curlrc"
48dotfile "editrc"
49dotfile "gitconfig"
50dotfile "gitignore_global"
51dotfile "inputrc"
52dotfile "npmrc"
53dotfile "profile"
54dotfile "ssh/config"
55dotfile "tmux.conf"
56dotfile "vimrc"
57dotfile "wgetrc"
58
59try apt-get update -y
60# shellcheck disable=SC2046
61try apt-get install -y --no-install-recommends $(tr '\n' ' ' < ./apt.list)
62
63command -v fd || try ln -s /usr/bin/fdfind /usr/bin/fd