-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcloak.sh
executable file
·75 lines (69 loc) · 2.08 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/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: 09/14/2024
# License: GPL 2 or higher
declare -r NAME="cloak"
declare -r VERSION="0.5.1"
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 "-s --show |- show hidden system files"
echo "-i --invisible |- hide your system files"
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
defaults write com.apple.finder AppleShowAllFiles YES
killall -KILL Finder
;;
-c|--cloak)
fileCheck
echo " Cloaking $FILE ..."
chflags -H -R hidden "$FILE"
echo " Removing $FILE location from Spotlight's index..."
defaults write com.apple.finder AppleShowAllFiles NO
killall -KILL Finder
mdutil $FILE >/dev/null
;;
-s|--show)
echo " Showing hidden system files"
defaults write com.apple.finder AppleShowAllFiles YES
killall -KILL Finder
;;
-i|--invisible)
echo " Hiding system files"
defaults write com.apple.finder AppleShowAllFiles NO
killall -KILL Finder
;;
-v|--version)
echo " $NAME version: $VERSION"
echo " System requirements: Mac OSX.5 Leopard or higher"
;;
esac
exit 0