To add a command that is trigger-able from spotlight:
- create a file with extension
.command
. - write the shell scripts in the file.
- suggest to add the following code to clost the terminal automatically.
-
osascript -e 'tell application "Terminal" to quit' & exit
-
- Run
chmod +x <yourfile>.command
to make it executable.
Example:
# lan.command
# to list available network services:
# networksetup listallnetworkservices
networksetup -setnetworkserviceenabled "USB 10/100/1000 LAN" off
networksetup -setnetworkserviceenabled Wi-Fi on
osascript -e 'tell application "Terminal" to quit' &
exit
# wifi.command
# to list available network services:
# networksetup listallnetworkservices
networksetup -setnetworkserviceenabled "USB 10/100/1000 LAN" off
networksetup -setnetworkserviceenabled Wi-Fi on
osascript -e 'tell application "Terminal" to quit' &
exit
- create a file with extension
.applescript
. - Write the script in the file.
- Execute Compile Application in command palette (command + shift + p).
- Make sure the extension settings: uncheck
Execute Only
,Startup Screen
andStay Open
. - the command will compile and output a
.app
application, which is executable from spotlight.
- Make sure the extension settings: uncheck
.applescript
files can run with command line too: osascript filename.applescript
- new a file with Script Editor, and export as format Text so that plain editor could read the content as well.
- Write the script in the file.
- File > Export
- File Format: Application
- Uncheck Options: Show startup screen, Stay open after run handler and Run-only
- Code Sign: Don't Code Sign