forked from xeoron/Cloak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloak.sh
executable file
·59 lines (53 loc) · 1.49 KB
/
cloak.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
56
57
58
59
#!/bin/bash
# File: cloak.sh
# Purpose: to make files and folders hidden or shown in OS X's Desktop, Finder, and Spotlight
# Author: Jason Campisi
# Date: 6/23/2013
# License: GPL 2 or higher
declare -r NAME="Cloak"
declare -r VERSION="0.2.7"
option=$1
FILE=$2
function fileCheck {
if [ ! -n "$FILE" ]; then
echo " $NAME Error - File or folder name is not set!"
exit 1;
elif [ ! -e $FILE ]; then
echo " $NAME Error - The location of '$FILE' does not exist!"
exit 1;
fi
}
if [ -z "$option" ]; then #if option is not set
option="-h"
fi
case $option in
-h|--help)
echo "Usage: $NAME <option> /location/to/folder"
echo " "
echo "$NAME any file/folder from Finder and Spotlight on your Mac"
echo "-c --cloak location from Finder and Spotlight"
echo "-u --uncloak location from Finder and Spotlight"
echo "-v --version"
echo "-h --help"
echo " "
;;
-u|--uncloak)
fileCheck
echo " Uncloaking $FILE ..."
chflags -H -R nohidden "$FILE"
echo " Adding $FILE location to Spotlight's index..."
mdimport $FILE
;;
-c|--cloak)
fileCheck
echo " Cloaking $FILE ..."
chflags -H -R hidden "$FILE"
echo " Removing $FILE location from Spotlight's index..."
mdutil $FILE >/dev/null
;;
-v|--version)
echo " $NAME version: $VERSION"
echo " System requirements: Mac OSX.5 Leopard or higher"
;;
esac
exit 0