Advertisement
cmurillo

Mac OS X Terminal tips

Jul 23rd, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.13 KB | None | 0 0
  1. # OS X Terminal tips
  2.  
  3. # Man pages as PDF (source: osxdaily.com)
  4. # If you’re tired of looking over a man page within the Terminal, you can launch any man page into Preview with the following command:
  5. man -t ipconfig | open -f -a /Applications/Preview.app
  6. # You can save to PDF from Preview for later reading
  7.  
  8. # To open a terminal window by right-clicking on a Finder folder:
  9. #    Go to System Preferences and click on “Keyboard”
  10. #    Select the “Keyboard Shortcuts” tab and click on “Services” from the left menu
  11. #    Scroll on the right until you see “New Terminal at Folder” and check the box next to it to enable the feature
  12. #    Close System Preferences
  13.  
  14. # To ensure a small amount of network activity happens on a regular basis
  15. ping -i 10 -q ADDRESS
  16. # -i 10 tells ping to wait 10 seconds between sending each packet, -q means quiet output (ADDRESS may be whatever IP or domain name you choose to ping)
  17.  
  18. # Bash remembers the previous commands you input in "history" (actually they are stored in the file ~/.bash_history)
  19. # list the history entries
  20. $ history
  21.  
  22. #delete the whole history
  23. $ history -c
  24.  
  25. # delete a given entry
  26. $ history -d offset
  27.  
  28. # How many lines is storing your history?
  29. $ echo $HISTSIZE
  30.  
  31. # If your Terminal is losing the history (previously entered commands), try this:
  32. #   Check first in your home directory the permissions and who owns the file .bash_history
  33. $ ls -al .bash_history
  34. #   If for some reason the file is not owned by your username, will appear (for example) in the listing as:
  35. -rw-------    1 root      staff       32 Jul 11  2011 .bash_history
  36. #   Fix it with
  37. sudo chown [username] .bash_history
  38. #   (source: http://www.paulmc.org/2009/01/enable-bash-history-in-terminal/ )
  39. #   Now close Terminal, open it again and you should be capable of seeing previously entered commands by pressing the up arrow (that is, if you're using bash as your Terminal shell - - the default).
  40.  
  41. # Make sure wich shell is running your Terminal (the above tips work in bash, BTW)
  42. $ echo $SHELL
  43.  
  44. # OS X Lion Terminal
  45. # If you don't want Terminal to show the previous commands and window customizations on a new session (and you don't want to disable System Preferences > General > Restore windows when quitting and re-opening windows):
  46. $ defaults write com.apple.Terminal NSQuitAlwaysKeepsWindows -bool false
  47. # BTW, that "grey text" with the history is not the content of ~/.bash_history, it's stored in the folder
  48. $ ~/Library/Saved\ Application\ State/com.apple.Terminal.savedState/
  49.  
  50. # Terminal shows the message 'You have mail':
  51. #You can access the mail by simply using the command
  52.  
  53. mail
  54. #This launches you into Mail, and it will right away show you a list of messages that are stored there. If you want to see #the content of the first message, use
  55. t
  56. #This will show you the content of the first message, in full. You'll need to scroll down through the message to view it #all, by hitting the down-arrow key.
  57. #If you want to jump to the end of the message, use the
  58. #spacebar
  59. #If you want to abort viewing the message, use
  60. q
  61. #To view the next message in the queue use
  62. n
  63. #... assuming there's more than one message.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement