text MAC OS X相关
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text MAC OS X相关相关的知识,希望对你有一定的参考价值。
# to hide icons
defaults write com.apple.finder CreateDesktop false
killall Finder
# to unhide icons
defaults write com.apple.finder CreateDesktop true
killall Finder
# Disable Screenshot Drop Shadows
defaults write com.apple.screencapture disable-shadow -bool TRUE
killall SystemUIServer
# Enable Screenshot Drop Shadows
defaults write com.apple.screencapture disable-shadow -bool FALSE
killall SystemUIServer
# Change Screenshot file format
defaults write com.apple.screencapture type PDF
defaults write com.apple.screencapture type png
killall SystemUIServer
# Change Screenshot Location
defaults write com.apple.screencapture location /drag/location/here
killall SystemUIServer
# Create a new default name scheme for screenshots
Don't like the phrase Apple uses to save your screenshots? Traditionally, it's "Screen Shot - [date] - [time]", but you can change "Screen Shot" to any word you please.
defaults write com.apple.screencapture name "New Screen Shot Name"
killall SystemUIServer`
Get bored of your new name scheme? Go back to the default by typing as follows:
defaults write com.apple.screencapture name ""
killall SystemUIServer
# Show Hidden Files and Folders
defaults write com.apple.finder AppleShowAllFiles -bool TRUE
killall Finder
# Stress Test Your Mac
yes
# View File System Usage
sudo fs_usage
# Remove Duplicate “Open With…” Entries
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
# Enable Text Selection in Quick Look
defaults write com.apple.finder QLEnableTextSelection -bool TRUE
killall Finder
# Check the Uptime Of Your Mac
uptime
# Display A Custom Message At The Login Window
sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText "Hey, Sticky Hands!"
# Next time you log out or restart your Mac, your message will appear. To remove the message entirely:
sudo defaults delete /Library/Preferences/com.apple.loginwindow LoginwindowText
# Download a File Without a Browser
curl -O http://appldnld.apple.com/iTunes11/091-6058.20130605.Cw321/iTunes11.0.4.dmg
#Shutdown Your Mac, With or Without a Delay
To shut down your Mac immediately:
$ sudo shutdown -h now
To restart your Mac immediately:
$ sudo shutdown -r now
We can even add a time delay (in minutes) if we wish:
$ sudo shutdown -r +60
# Prevent Your Mac From Sleeping
$ caffeinate
Entering the command on its own will keep the Mac awake until you stop it by pressing Ctrl-C. You can add a time parameter with:
$ caffeinate -u -t 600
# Get Your Network IP Address
$ ipconfig getifaddr en0 (en can be selected automatically)
# Get Your External IP Address
$ curl ipecho.net/plain; echo
# Prevent Apps From Saving to iCloud by Default
$ defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool FALSE
Quit and relaunch any app that uses iCloud and now any new documents will default to your Mac in the save dialog rather than iCloud.
To revert the changes:
$ defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool TRUE
# Make the Icon of Any Hidden App in the Dock Translucent
Hiding apps when you’re not using them is a great way to free up screen space but there’s not really any way to distinguish between which app is hidden and which isn’t. We can alter the Dock so any apps that are hidden will have a translucent icon:
$ defaults write com.apple.Dock showhidden -bool TRUE
$ killall Dock
# Make Your Mac Talk
$ say "This Mac runs OS X, not OS ex"
Read any text file
$say -f /path/to/file.txt
# Turn Off Dashboard
$ defaults write com.apple.dashboard mcx-disabled -boolean TRUE
$ killall Dock
# Hide non-active apps in your Dock
Dock too crowded, use this to make it show only active apps.
defaults write com.apple.dock static-only -bool TRUE
killall Dock
# Dull hidden apps in the Dock
You can go even further and make the Dock dim apps that aren't visible on screen.
defaults write com.apple.Dock showhidden -bool TRUE
killall Dock
# Make holding down a key repeat characters
Here's one we really like. When you hold down a key on your Mac's keyboard, it either displays a pop up of additional characters or does nothing. Here's how to make it repeat the character you tapped, just like it used to do.
defaults write -g ApplePressAndHoldEnabled -bool FALSE
# Enable an iOS-like power chime when connected to power
Use this to make your Mac chime like an iPhone when you plug in the charger.
defaults write com.apple.PowerChime ChimeOnAllHardware -bool true; open /System/Library/CoreServices/PowerChime.app
Disable:
defaults write com.apple.PowerChime ChimeOnAllHardware -bool FALSE; killall PowerChime
# Disable Auto-restore in Preview using Terminal on the Mac
To prevent that, and launch Preview without any documents, use this Terminal command:
defaults write com.apple.Preview NSQuitAlwaysKeepsWindows -bool FALSE
To change back to the default, re-type the command, replacing FALSE with TRUE. To do the same thing in QuickTime X, replace com.apple.Preview with com.apple.QuickTimePlayerX
# 26 Make the Dock slide more quickly using Terminal on the Mac
If you use Show and Hide Dock, you'll notice that when you drag the mouse pointer onto the bottom of the screen, or whichever edge you keep the Dock, there's a delay before the Dock slides into view. You can eliminate that delay with these commands:
defaults write com.apple.dock autohide-delay -float 0
killall Dock
The '0' represents the delay before the Dock slides into view, so if you want to reduce it, but not eliminate it altogether, replace the '0' with another value, measured in seconds.
To revert to the default, type:
defaults delete com.apple.dock autohide-delay
killall Dock
You can also change the speed at which the Dock slides. Again, it's done by modifying a delay. So, to make it instant, type:
defaults write com.apple.dock autohide-time-modifier -float 0
killall Dock
# Add spacers to your Dock
You can organize your Dock's many icons by adding in blank spaces with this handy terminal command:
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock
Repeat this command for each spacer you'd like for your Dock. To remove a spacer, you can drag it out to the right until you see the poof icon.
# Reveal open TCP and UDP ports and the applications using them
lsof
When tracking down problems, particularly security-related issues, it's often helpful to know which applications are currently communicating on the network. The lsof (list open files) command does that. With the -i option, it lists all the open connections in progress and the names of the applications using them. The list can be long, and often you're only interested in applications that have established sessions, not partially open ones (for example, someone trying to sign on). To reduce the command's output, you can pipe it to the grep command and filter on the word ESTABLISHED to list only functional connections:
$ lsof -i | grep ESTABLISHED
#########################################################
# opendiff: Compare and merge files and directores
opendiff takes two file or directory names as arguments and passes them to the little-known (because it's hidden) FileMerge utility in OS X's Utilities folder. FileMerge can find the differences between two text files, as well as compare two directories with the ability to merge them into a single directory that eliminates duplicate files. The syntax is simple and produces the display shown below:
$ opendiff Contract1.rtf Contract2.rtf
#########################################################
#sysctl: Get CPU information and other internal secrets
The official purpose of the sysctl utility is to get or set kernel state values. Unless you know what you're doing, you don't want to set kernel state values. But looking at them is harmless -- and can be informative.
For example, the example below displays the machine CPU type, which can be useful to know for certain system administration chores. You can use sysctl to control decisions in a Bash script as well. Run sysctl -a to get a list of all the kernel variables available for inspection. You might find some others you'd like to inspect.
For example:
$ sysctl -n machdep.cpu.brand_string
might display:
Intel(R) Core(TM) i5 CPU 750 @ 2.67GHz
###################
systemsetup: Perform various system configuration operations
The systemsetup command lets you retrieve and alter a wide range of configuration values normally set from the graphical System Preferences application. Run systemsetup help to get a complete list of options.
One popular setting is to configure a system to set its clock based on a network time source, as shown below. You'll undoubtedly find useful reasons to set other values.
$ systemsetup -setnetworktimeserver us.pool.ntp.org
###################
textutil: Convert between various text file formats
Converting text file formats is a black art. In the ancient days before OS X, back in the 1990s, Apple included a text conversion program with what was then called System or Mac OS. In OS X, that program was replaced by textutil, which is even more useful because it can convert files with today's complex HTML, docs, and other formats.
To convert a file, just specify the -convert option, the new file type, the path to the source file, and the path to the output file using the -output option.
The example below shows how to convert a Microsoft Word file into HTML. textutil figures out the source file type automatically. If you want to see what textutil thinks your file's type is, use the -info option, also shown below. Though textutil isn't perfect, you gotta remember -- it's also not the 1990s.
To convert a Word document into HTML:
$ textutil -convert html MyWordFile -output /tmp/webfile.html
To display textutil's interpretation of a document's file format:
$ textutil -info MyWordFile
It might display:
Type: Word format
Size: 45568 bytes
Length: 4354 characters
Title:
Author: Mel Beckman
Last Editor: Mel Beckman
Subject:
Keywords:
Created: 2012-07-08 09:11:00 -0700
Last Modified: 2012-09-13 11:52:00 -0700
Contents: Q. I have a question about wri...
###################
以上是关于text MAC OS X相关的主要内容,如果未能解决你的问题,请参考以下文章