Terminal Hacks
Make a beep sound when finished
# make a beep, in OS X badge will show if terminal not in foreground
tput bel
# or
echo -e "\a"
ping -c 5 google.com && tput bel
Dirty StopWatch
# Use `ctrl-c` to stop
time cat
# Use `ctrl-d` to stop
time read
Copy and Paste in terminal
echo "hi" | pbcopy
pbcopy < file.txt
pbpaste
For linux user who want
pbcopy
orpbpaste
, please refer to osxs pbcopy for linux on superuser.com
Remove images metadata to protect privacy
exiftool -all= *.jpg
Bash Keyboard Shortcut
please refer to ss64
List open port
# For Mac OSX, you can use `lsof`
lsof -i:8080
# For Linux you may use `netstat`
String Editing
# using awk
ls -l | awk '{print $9}'
Mac OS X restarting services
# Fixed Finder crashes
killall -KILL Finder
# or option (=alt) + rightclicking the Finder icon in the Dock and selecting Relaunch
# Fixed Dock or Spaces crashes
killall -KILL Dock
# Fixed Menubar crashes
killall -KILL SystemUIServer
Convert plist
file to xml
# `com.apple.sidebarlists.plist` is originally stored as binary format
cp ~/Library/Preferences/com.apple.sidebarlists.plist <your-folder>
plutil -convert xml1 com.apple.sidebarlists.plist
# convert XML .plist to binary
plutil -convert binary1 <your-xml-plist-file>