diff options
author | Case Duckworth | 2024-06-10 23:07:11 -0500 |
---|---|---|
committer | Case Duckworth | 2024-06-10 23:07:11 -0500 |
commit | ac25270e13b669ef153889855da2eb321af58fa6 (patch) | |
tree | 7416e6f9b5f2569c01454059ea4173abf6d4bf94 | |
parent | Change prompt (diff) | |
download | dots-ac25270e13b669ef153889855da2eb321af58fa6.tar.gz dots-ac25270e13b669ef153889855da2eb321af58fa6.zip |
Change spacing
-rwxr-xr-x | dots.sh | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/dots.sh b/dots.sh index 5036e30..e2439f0 100755 --- a/dots.sh +++ b/dots.sh | |||
@@ -6,25 +6,25 @@ FORCE=false | |||
6 | DIR="$(dirname "$(realpath "$0")")" | 6 | DIR="$(dirname "$(realpath "$0")")" |
7 | 7 | ||
8 | main() { | 8 | main() { |
9 | action=homify | 9 | action=homify |
10 | while getopts hqnfdx OPT | 10 | while getopts hqnfdx OPT |
11 | do | 11 | do |
12 | case "$OPT" in | 12 | case "$OPT" in |
13 | (h) usage; exit 0 ;; | 13 | (h) usage; exit 0 ;; |
14 | (q) QUIET=true ;; | 14 | (q) QUIET=true ;; |
15 | (n) NORUN=true ;; | 15 | (n) NORUN=true ;; |
16 | (f) FORCE=true ;; | 16 | (f) FORCE=true ;; |
17 | (d) action=dotify ;; | 17 | (d) action=dotify ;; |
18 | (x) set -x ;; | 18 | (x) set -x ;; |
19 | (*) usage; exit 1 ;; | 19 | (*) usage; exit 1 ;; |
20 | esac | 20 | esac |
21 | done | 21 | done |
22 | shift $((OPTIND - 1)) | 22 | shift $((OPTIND - 1)) |
23 | "$action" "$@" | 23 | "$action" "$@" |
24 | } | 24 | } |
25 | 25 | ||
26 | usage() { | 26 | usage() { |
27 | cat<<EOF | 27 | cat<<EOF |
28 | Usage: $0 [-h] [-q] [-n] [-f] [-x] [-d] [FILE] [FIND_ARGS...] | 28 | Usage: $0 [-h] [-q] [-n] [-f] [-x] [-d] [FILE] [FIND_ARGS...] |
29 | Flags: | 29 | Flags: |
30 | -h Show this help and exit | 30 | -h Show this help and exit |
@@ -49,33 +49,33 @@ log() { $QUIET || echo >&2 "* $@"; } | |||
49 | run() { log "$@"; $NORUN || "$@"; } | 49 | run() { log "$@"; $NORUN || "$@"; } |
50 | 50 | ||
51 | mklink() { # mklink SOURCE DEST | 51 | mklink() { # mklink SOURCE DEST |
52 | # make hardlinks to DEST from SOURCE -- making directories | 52 | # make hardlinks to DEST from SOURCE -- making directories |
53 | $NORUN || test -d "$(dirname "$2")" || run mkdir -p "$(dirname "$2")" | 53 | $NORUN || test -d "$(dirname "$2")" || run mkdir -p "$(dirname "$2")" |
54 | if ! test -f "$2" | 54 | if ! test -f "$2" |
55 | then run ln "$1" "$2" | 55 | then run ln "$1" "$2" |
56 | elif test -f "$2" && "$FORCE" | 56 | elif test -f "$2" && "$FORCE" |
57 | then run ln -f "$1" "$2" | 57 | then run ln -f "$1" "$2" |
58 | else log "$2 exists: skipping" | 58 | else log "$2 exists: skipping" |
59 | fi | 59 | fi |
60 | } | 60 | } |
61 | 61 | ||
62 | getfiles() { | 62 | getfiles() { |
63 | d="$1"; shift | 63 | d="$1"; shift |
64 | find "$d" -type f -a -not -name "$(basename "$0")" "$@" | 64 | find "$d" -type f -a -not -name "$(basename "$0")" "$@" |
65 | } | 65 | } |
66 | 66 | ||
67 | homify() { | 67 | homify() { |
68 | getfiles "$DIR" "$@" | | 68 | getfiles "$DIR" "$@" | |
69 | while read -r dot | 69 | while read -r dot |
70 | do mklink "$dot" "$HOME/.${dot#$DIR/}" | 70 | do mklink "$dot" "$HOME/.${dot#$DIR/}" |
71 | done | 71 | done |
72 | } | 72 | } |
73 | 73 | ||
74 | dotify() { | 74 | dotify() { |
75 | getfiles "$@" | | 75 | getfiles "$@" | |
76 | while read -r file | 76 | while read -r file |
77 | do mklink "$file" "$DIR/${file#.}" | 77 | do mklink "$file" "$DIR/${file#.}" |
78 | done | 78 | done |
79 | } | 79 | } |
80 | 80 | ||
81 | main "$@" | 81 | main "$@" |