-
Notifications
You must be signed in to change notification settings - Fork 333
/
mac
executable file
·180 lines (165 loc) · 4.28 KB
/
mac
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/bin/sh
###########################################################################
# mac CLI (mac command line tools) - macOS command line tools for developers
###########################################################################
# Version: 2.0
# Date: December 8, 2015
# Author: Gabriel Guarino
#
# Collection of useful functions to automate macOS common tasks
#
###########################################################################
# Mac CLI directory
MAC="$(dirname "$0")"
#--------------------------------------------------------------------
# Configuration
#--------------------------------------------------------------------
export echocommand="true"
#--------------------------------------------------------------------
# Parameters
#--------------------------------------------------------------------
export fn=$1
export firstParameter=$2
export secondParameter=$3
export allParameters=${@:2}
#--------------------------------------------------------------------
# Colors
#--------------------------------------------------------------------
export GREEN='\033[0;32m'
export GRAY='\033[0;37m'
export LIGHTBLUE='\033[1;34m'
export LIGHTGREEN='\033[1;32m'
export WHITEBOLD='\033[1;37m'
export RED='\033[1;31m'
export NC='\033[0m' # No Color
#--------------------------------------------------------------------
# List of Commands
#--------------------------------------------------------------------
COMMANDS=(
list
help
usage
categories
general
search
network
dns
ssh
webdev
performance
terminal
git
web_utilities
homebrew
image
magento
update
upgrade
uninstall
lock
restart
sleep
display
shutdown
uptime
volume
volume:ismute
volume:mute
volume:unmute
hidden:show
hidden:hide
screensaver
folders:list
folder:size
dock:add-space
bluetooth:status
bluetooth:enable
bluetooth:disable
wifi:status
wifi:scan
wifi:enable
wifi:disable
eject-all
battery
info
find:text
find:biggest-files
find:biggest-directories
zip:extract
gzip:compress
gzip:extract
tar:compress
tar:extract
find:recent
search:replace
speedtest
ports
ip:local
ip:public
dns:list
dns:add
dns:remove
dns:flush
hosts:edit
ssh:download-file
ssh:download-folder
ssh:sync:local
ssh:sync:remote
ssh:upload
ssh:public-key
ssh:list
system
temp
memory
trash:empty
trash:size
git:config
git:open
git:create:branch
git:branches:date
git:undo-commit
git:log
git:branch
git:branch:rename
git:branch:remove-local
git:branch:remove-remote
git:branch
git:settings
git:add-removed
git:size
brew:update
)
## ---- END OF COMMANDS; Comment required for bash_completion------
if [ -z "$fn" ] || [[ "$#" -lt "1" ]]; then
fn="list"
fi
#--------------------------------------------------------------------
# Help
#--------------------------------------------------------------------
# Documentation / Help
source "$MAC/mac-cli/misc/help"
#--------------------------------------------------------------------
# Catch command not found
#--------------------------------------------------------------------
if [[ ! " ${COMMANDS[@]} " =~ " ${fn} " ]]; then
echo "${RED}Command not found: '${fn}' $(test ! -z "$allParameters" -a "$allParameters" != " " && echo "\nParameters: $allParameters" || echo "")${NC}"
read -p "Choose a category for which to list help/usage... ($(categoriesList)) " category # Ask user for a category to print usage
if [ ! -z "${category}" ]; then
echo "$(usageList ${category})\n" # Show help/usage for user-selected category
echo "$(printAdditionalHelp)"
else
kill -INT $$ # Exit
fi
fi
#--------------------------------------------------------------------
# Plugins
#--------------------------------------------------------------------
source "$MAC/mac-cli/plugins/brew"
source "$MAC/mac-cli/plugins/general"
source "$MAC/mac-cli/plugins/git"
source "$MAC/mac-cli/plugins/network"
source "$MAC/mac-cli/plugins/dns"
source "$MAC/mac-cli/plugins/performance"
source "$MAC/mac-cli/plugins/search"
source "$MAC/mac-cli/plugins/ssh"
source "$MAC/mac-cli/plugins/volume"