Table of contents
- get env variables
- get local ip
- convert file/image to base64
- ENABLE ROOT
- Copy terminal output directly to clip board
- Restart
- Check Permissions
- Schedule Mac to power on or wake, M refers to Monday
- Schedule Mac to shut down:
- View your current schedules:
- Cancel your schedules:
- Create Ram Disk For Intellij
- Launching Apps From Terminal
- DEBUGGING - OBSCURE ISSUES
- Resources
get env variables
env
get local ip
osascript -e "IPv4 address of (system info)"
ifconfig | grep "inet "
convert file/image to base64
base64 -i ./post_u_north_gate.jpg | pbcopy
cat ./post_u_north_gate.jpg | openssl base64 | tr -d '\n' | pbcopy
./post_u_north_gate.jpg | openssl base64 | tr -d '\n' | pbcopy
ENABLE ROOT
dsenableroot
Disable Root
dsenableroot -d
Copy terminal output directly to clip board
pbcopy < ~/.ssh/id_rsa.pub
Restart
sudo shutdown now
#specific time
sudo shutdown hhmm
Check Permissions
ls -lO /System
Schedule Mac to power on or wake, M refers to Monday
sudo pmset repeat wake M 8:00:00
Schedule Mac to shut down:
sudo pmset repeat shutdown F 20:00:00
View your current schedules:
pmset -g sched
Cancel your schedules:
sudo pmset repeat cancel
Create Ram Disk For Intellij
diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nomount ram://XXXXX`
Replace the
X
characters with a number that represents the block size for the total capacity of your RAM Disk.
diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nomount ram://8388608
create ramdisk
if [ ! -d /Volumes/JetBrainsKeys/tbcore/intellij ]; then diskutil erasevolume HFS+ JetBrainsKeys `hdiutil attach -nomount ram://6291456`;
mkdir -p /Volumes/JetBrainsKeys/intellij;
chmod -R 777 /Volumes/JetBrainsKeys;
#mkdir -p /Volumes/JetBrainsKeys/tbcore/intellij/caches;
#ln -s /Volumes/JetBrainsKeys/intellij/caches/Users/bpaxton/Library/Caches/JetBrains/IntelliJIdea2022.1/caches;
fi
Launching Apps From Terminal
Terminal command to launch macOS gui apps is appropriately called
open
and here is how it works at its most simple:
open -a ApplicationName
That will open the defined app named “ApplicationName”
open
at the command prompt, you’ll return the basic help file with details on how to properly use the command with a variety of flags and syntax.Usage
:open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-b ] [-a ] [filenames] [--args arguments]
Help
: Open opens files from a shell. By default, open each file using the default application for that file. If the file is in the form of a URL,
the file will be opened as a URL.Options
:
-a
: Opens with the specified application.
-b
: Opens with the specified application bundle identifier.
-e
: Opens with TextEdit.
-t
: Opens with default text editor.
-f
: Reads input from standard input and opens with TextEdit.
-F --fresh
: Launches the app fresh, that is, without restoring windows. Saved persistent state is lost, excluding Untitled documents.
-R, --reveal
: Selects in the Finder instead of opening.
-W, --wait-apps
: Blocks until the used applications are closed (even if they were already running).
--args
: All remaining arguments are passed in argv to the application’s main() function instead of opened.
-n, --new
: Open a new instance of the application even if one is already running.
-j, --hide
: Launches the app hidden.
-g, --background
: Does not bring the application to the foreground.
-h, --header
: Searches header file locations for headers matching the given filenames, and opens them.
In other words, example simple command syntax could look like the following, opening “ApplicationName” with the file located at the path
/file/to/open
:
open -a ApplicationName /file/to/open
You’ll note you don’t need the full path to the application name, but you would need the full path to a file name.
The usage is likely self-explanatory to those who have experience in the command line environment, but for those who are new to the Terminal, don’t
be too confused, it is easy to use, and we’ll
explain.
For example, if you want to edit/etc/motd
withTextWrangler
to change your Message of the Day, but you hate the command line editorsnano
andvi
, here is what you’d type:
open -a TextWrangler /etc/motd
open -a Adobe\ Photoshop\ CS
Launching GUI Apps as root from the Command Line
sudo open -a TextEdit /tmp/magicfile
Creating Shell Aliases for Frequently Launched GUI Apps
First launch the profile or .bash_profile into a text editor:
nano .profile
or
open -e .profile
add the following to a new line:
alias photoshop="open -a Adobe\ Photoshop\ CS"
This creates an alias, so that the
open -a Adobe\ Photoshop CS
command is now shortened to simplyphotoshop
.