-
Notifications
You must be signed in to change notification settings - Fork 0
/
dxignore.sh
executable file
·56 lines (48 loc) · 1.16 KB
/
dxignore.sh
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
#!/bin/bash
help () {
echo "dxignore : Tools for disable dropbox sync"
echo ""
echo "dxignore [file] ignore a file"
echo "dxignore -r [file] don't ignore a file"
echo "dxignore -g [file] say if a file is ignored"
echo "dxignore -h help"
}
set() {
attr -s com.dropbox.ignored -V 1 "$file" &> /dev/null && echo "$file will be ignored by Dropbox" || echo "Error with file $file"
}
get () {
attr -g com.dropbox.ignored "$file" &> /dev/null && echo "$file is ignored by Dropbox" || echo "$file isn't ignored by Dropbox"
}
remove () {
attr -r com.dropbox.ignored "$file" &> /dev/null && echo "$file won't be ignoré by Dropbox" || echo "Error with file $file"
}
if [ $# -eq 1 ] && [ "$1" != "-h" ]; then
action="set" # Set ignoring by default
file=$1
else
while getopts "hr:g:" arg; do
case $arg in
h)
help
exit 0
;;
r)
file=$OPTARG
action="remove"
;;
g)
file=$OPTARG
action="get"
;;
*)
echo "Bad usage"
help
exit 1
esac
done
fi
if [ ! -f "$file" ] && [ ! -d "$file" ] ; then
echo "$file file doesn't exist"
exit 1
fi
$action