Wednesday, September 30, 2015

Bash shell

Which Bash config to run depends on two conditions -- Interactive vs. Non-interactive, and Login vs. Non-login

Login shell
- Start with 'bash --login' or 'bash -'
- Run the following config files: /etc/profile, ~/.bash_profile, then ~/.bash_login and lastly ~/.profile. When login shells exit, they read ~/.bash_logout.

Nonlogin shell
- Read .bashrc
- Should not put any output-producing code in this file because the standard stream could be redirected.

Wednesday, September 9, 2015

Keep tracks of defaults write and Useful defaults write commands

In .bashrc, create the line

PROMPT_COMMAND='echo "$(history 1 | grep "defaults")" | sed '/^$/d' >> ~/Documents/defaults.txt'

To undo the changes, use 'defaults delete'. For example,
defaults write xxx - bool false
defaults delete xxx

- Change to transparent dock in Mavericks

defaults write com.apple.dock hide-mirror -bool true;killall Dock

- Change screen capture file format

defaults write com.apple.screencapture type jpg; killall SystemUIServer
defaults write com.apple.screencapture disable-shadow -bool false

- Add 'Save as' back to applications

defaults write com.apple.iWork.Keynote ApplePersistence - bool no
defaults write com.apple.TextEdit ApplePersistence - bool no
defaults write com.apple.Preview ApplePersistence - bool no