]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | ||
3 | #NOTE: .zshenv XDG paths are hardcoded to allow non-zsh install | |
4 | ||
5 | # test | |
6 | devnull=/dev/null | |
7 | if [ "$1" = "test" ]; then | |
8 | echo "Running test -- no changes will be applied" | |
9 | devnull=/dev/stdout | |
10 | _cd() { | |
11 | cd $*; | |
12 | echo " cd $*"; | |
13 | echo "\$PWD=$PWD"; | |
14 | } | |
15 | alias cd="_cd" | |
16 | alias mkdir="echo mkdir" | |
17 | alias ln="echo ln" | |
18 | alias rm="echo rm" | |
19 | alias sh="echo sh" | |
20 | fi | |
21 | ||
22 | # create preferred folder structure | |
23 | cd ~ | |
24 | mkdir -p bin etc share share/fonts .urxvt/ext .icons .themes .gnupg .ssh >$devnull 2>&1 | |
25 | mkdir -pm 700 var/tmp var/tmp/vim >$devnull 2>&1 | |
26 | cd - >$devnull | |
27 | ||
28 | # ensure ostype | |
29 | if [ -z "$OSTYPE" ]; then | |
30 | OSTYPE=`uname -s | tr '[:upper:]' '[:lower:]'` | |
31 | fi | |
32 | ||
33 | # accomodate multiple userlands | |
34 | lnargs=-sfnv | |
35 | case "$OSTYPE" in | |
36 | freebsd*) lnargs=-sFhv;; | |
37 | netbsd|openbsd*) lnargs=-sfhv;; | |
38 | esac | |
39 | ||
40 | l() { | |
41 | # TODO: use install? | |
42 | [ -L "$1" -o \! -e "$1" ] && ln $lnargs "${2:-$PWD/$x}" "$1" || \ | |
43 | echo "!!! File exists and is not a link: $1" | |
44 | } | |
45 | ||
46 | # link files | |
47 | find base -mindepth 1 -maxdepth 1 | while read -r x; do | |
48 | l "$HOME/`basename "$x"`" | |
49 | done | |
50 | find bin share -mindepth 1 -maxdepth 1 | while read -r x; do | |
51 | l "$HOME/$x" | |
52 | done | |
53 | find fonts -mindepth 1 -maxdepth 1 -type d | while read -r x; do | |
54 | l "$HOME/share/fonts/`basename "$x"`" | |
55 | done | |
56 | find xdg -mindepth 1 -maxdepth 1 | while read -r x; do | |
57 | l "$HOME/etc/`basename "$x"`" | |
58 | done | |
59 | find urxvt-ext -mindepth 1 -maxdepth 2 -type f -perm -111 | while read -r x; do | |
60 | l "$HOME/.urxvt/ext/`basename $x`" | |
61 | done | |
62 | find xorg/icons -mindepth 1 -maxdepth 2 -type d | while read -r x; do | |
63 | if [ -e "$x/index.theme" ]; then | |
64 | d="$HOME/.icons/`basename "$x"`" | |
65 | l $d | |
66 | which gtk-update-icon-cache >/dev/null 2>&1 && gtk-update-icon-cache -qtf $d | |
67 | unset d | |
68 | fi | |
69 | done | |
70 | find xorg/themes -mindepth 1 -maxdepth 1 -type d | while read -r x; do | |
71 | l "$HOME/.themes/`basename "$x"`" | |
72 | done | |
73 | find gpg -mindepth 1 -maxdepth 1 \! -name '*.gpg' | while read -r x; do | |
74 | l "$HOME/.gnupg/`basename "$x"`" | |
75 | done | |
76 | if which gpg >/dev/null 2>&1; then | |
77 | find gpg -mindepth 1 -maxdepth 1 -name '*.gpg' | while read -r x; do | |
78 | gpg --import "$x" | |
79 | done | |
80 | fi | |
81 | find ssh -mindepth 1 -maxdepth 1 | while read -r x; do | |
82 | l "$HOME/.ssh/`basename "$x"`" | |
83 | done |