aboutsummaryrefslogtreecommitdiffhomepage
path: root/setup.sh
blob: d4c4a4c931b2af11e86b4a0bdedd97669c954bd7 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash

# Requirements. {{{1

ok=1
for exe in \
    curl \
    git \
    go \
    gunzip \
    ; \
do
    if which "$exe" >/dev/null; then
        :
    else
        echo "error: $exe is missing" >&2
        ok=0
    fi
done
if [[ $ok = 0 ]]; then
    exit 1
fi

# XDG Base Directories. {{{1
(
    source ~/dotfiles/.zshenv
    for dir in \
        "$XDG_CONFIG_HOME" \
        "$XDG_CACHE_HOME" \
        "$XDG_DATA_HOME" \
        "$XDG_STATE_HOME" \
        ; \
    do
        if [ ! -d "$dir" ]; then
            echo "dir: $dir"
            mkdir -p "$dir"
        fi
    done
)

# Configurations. {{{1

# Make symlinks to dot files. {{{2
for name in \
    .vimrc \
    .zshenv \
    .zshrc \
    ; \
do
    if [ ! -L ~/"$name" ]; then
        echo "symlink: ~/$name"
        ln -s -f ~/dotfiles/"$name" ~/"$name"
    fi
done

# Make symlinks to dot directories. {{{2
for name in \
    alacritty \
    bat \
    git \
    newsboat \
    nvim \
    tmux \
    ; \
do
    if [ ! -L ~/.config/"$name" ]; then
        echo "symlink: ~/.config/$name"
        ln -s -f ~/dotfiles/.config/"$name" ~/.config/"$name"
    fi
done

# Tools. {{{1

# Golang: {{{2
for name in \
    gitalias/git-sw \
    ; \
do
    src_file="src/$name.go"
    bin_file="bin/$name"
    if [[ "$bin_file" -ot "$src_file" ]]; then
        echo "build: $bin_file"
        go build -o "$bin_file" "$src_file"
    fi
done

# Scripts. {{{1

# Make ~/bin directory. {{{2
if [ ! -d ~/bin ]; then
    echo "dir: ~/bin"
    mkdir ~/bin
fi
if [ ! -d ~/bin/gitalias ]; then
    echo "dir: ~/bin/gitalias"
    mkdir ~/bin/gitalias
fi

# Make symlinks to utility scripts. {{{2
for name in \
    tmux-pane-idx \
    gitalias/git-sw \
    ; \
do
    if [ ! -L ~/bin/"$name" ]; then
        echo "symlink: ~/bin/$name"
        ln -s -f ~/dotfiles/bin/"$name" ~/bin/"$name"
    fi
done

# Application-specific configurations. {{{1

# Alacritty {{{2
if [ ! -f ~/.config/alacritty/alacritty.local.yml ]; then
    echo "symlink: ~/.config/alacritty/alacritty.local.yml"
    if [[ "$(uname)" == "Darwin" ]]; then
        ln -s -f ~/.config/alacritty/alacritty.macos.yml ~/.config/alacritty/alacritty.local.yml
    else
        ln -s -f ~/.config/alacritty/alacritty.linux.yml ~/.config/alacritty/alacritty.local.yml
    fi
fi

# SKK {{{2
if [ ! -d ~/.config/skk ]; then
    echo "dir: ~/.config/skk"
    mkdir ~/.config/skk
fi

# SKK: download jisyo file. {{{2
if [ ! -f ~/.config/skk/jisyo.L ]; then
    echo "download: ~/config/.skk/jisyo.L"
    _compressed_jisyo="$(mktemp)"
    curl -fL -o "$_compressed_jisyo" https://skk-dev.github.io/dict/SKK-JISYO.L.unannotated.gz
    gunzip -cd "$_compressed_jisyo" > ~/.config/skk/jisyo.L
fi

# Zsh {{{2
if [ ! -d "$XDG_STATE_HOME/zsh" ]; then
    echo "dir: $XDG_STATE_HOME/zsh"
    mkdir -p "$XDG_STATE_HOME/zsh"
fi

# }}}
# }}}
# vim: foldmethod=marker