]>
Commit | Line | Data |
---|---|---|
189288f7 | 1 | #!/bin/sh |
d9362f34 | 2 | |
7197cc5c | 3 | #NOTE: .zshenv XDG paths are hardcoded to allow non-zsh install |
4 | ||
1f8bf106 | 5 | # test |
f993e922 | 6 | devnull=/dev/null |
7197cc5c | 7 | if [ "$1" = "test" ]; then |
f993e922 | 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" | |
9938f1e2 | 17 | alias ln="echo ln" |
18 | alias rm="echo rm" | |
f993e922 | 19 | alias sh="echo sh" |
9938f1e2 | 20 | fi |
21 | ||
fef6b2b5 | 22 | # create preferred folder structure |
ba63cd01 | 23 | cd ~ |
bdeaf2f0 | 24 | mkdir -p bin etc share share/fonts .urxvt/ext \ |
25 | .icons .themes .gnupg .ssh .termux >$devnull 2>&1 | |
f993e922 | 26 | mkdir -pm 700 var/tmp var/tmp/vim >$devnull 2>&1 |
27 | cd - >$devnull | |
5b39422d | 28 | |
a568f7fa | 29 | # ensure ostype |
3daa445f | 30 | if [ -z "$OSTYPE" ]; then |
f7960c69 | 31 | OSTYPE=`uname -s | tr '[:upper:]' '[:lower:]'` |
3daa445f | 32 | fi |
a568f7fa | 33 | |
34 | # accomodate multiple userlands | |
35 | lnargs=-sfnv | |
ba63cd01 | 36 | case "$OSTYPE" in |
f993e922 | 37 | freebsd*) lnargs=-sFhv;; |
7197cc5c | 38 | netbsd|openbsd*) lnargs=-sfhv;; |
138de127 | 39 | esac |
40 | ||
9938f1e2 | 41 | l() { |
f29cd560 | 42 | # TODO: use install? |
f993e922 | 43 | [ -L "$1" -o \! -e "$1" ] && ln $lnargs "${2:-$PWD/$x}" "$1" || \ |
44 | echo "!!! File exists and is not a link: $1" | |
9938f1e2 | 45 | } |
46 | ||
1f8bf106 | 47 | # link files |
f993e922 | 48 | find base -mindepth 1 -maxdepth 1 | while read -r x; do |
9938f1e2 | 49 | l "$HOME/`basename "$x"`" |
50 | done | |
ba63cd01 | 51 | find bin share -mindepth 1 -maxdepth 1 | while read -r x; do |
f993e922 | 52 | l "$HOME/$x" |
f29cd560 | 53 | done |
bf314d35 | 54 | find fonts -mindepth 1 -maxdepth 1 -type d | while read -r x; do |
55 | l "$HOME/share/fonts/`basename "$x"`" | |
56 | done | |
f993e922 | 57 | find xdg -mindepth 1 -maxdepth 1 | while read -r x; do |
7197cc5c | 58 | l "$HOME/etc/`basename "$x"`" |
7f0acd88 | 59 | done |
3fb394c5 | 60 | find urxvt-ext -mindepth 1 -maxdepth 2 -type f -perm -111 | while read -r x; do |
9938f1e2 | 61 | l "$HOME/.urxvt/ext/`basename $x`" |
805ce2dc | 62 | done |
3fb394c5 | 63 | find xorg/icons -mindepth 1 -maxdepth 2 -type d | while read -r x; do |
a568f7fa | 64 | if [ -e "$x/index.theme" ]; then |
fc768c23 | 65 | d="$HOME/.icons/`basename "$x"`" |
66 | l $d | |
67 | which gtk-update-icon-cache >/dev/null 2>&1 && gtk-update-icon-cache -qtf $d | |
68 | unset d | |
a568f7fa | 69 | fi |
90595fd4 | 70 | done |
3fb394c5 | 71 | find xorg/themes -mindepth 1 -maxdepth 1 -type d | while read -r x; do |
90595fd4 | 72 | l "$HOME/.themes/`basename "$x"`" |
7197cc5c | 73 | done |
bf314d35 | 74 | find gpg -mindepth 1 -maxdepth 1 \! -name '*.gpg' | while read -r x; do |
75 | l "$HOME/.gnupg/`basename "$x"`" | |
f7960c69 | 76 | done |
e1a1a1d1 | 77 | if which gpg >/dev/null 2>&1; then |
bf314d35 | 78 | find gpg -mindepth 1 -maxdepth 1 -name '*.gpg' | while read -r x; do |
79 | gpg --import "$x" | |
80 | done | |
81 | fi | |
bdeaf2f0 | 82 | for y in ssh termux; do |
83 | find $y -mindepth 1 -maxdepth 1 | while read -r x; do | |
84 | l "$HOME/.$y/`basename "$x"`" | |
85 | done | |
b133dc92 | 86 | done |