1.  Changing filetype and creator to iTunes

SetFile -c "hook" -t "MPG3" filename

2.  Granting admin privileges to a user via single user mode

/sbin/mount -uw /
launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist
dscl . append /Groups/admin GroupMembership <username>
reboot

(Press cmd-s to boot in single user mode)

3.  Resume scp uploads with rsync

rsync --partial --progress --rsh=ssh --checksum

4.  Show hidden files in Finder

defaults write com.apple.finder AppleShowAllFiles TRUE; killall Finder

5.  Open any Terminal output with TextEdit

cat filename | open -f

6.  Rename files in a folder (printf-like)

ls | xargs -I % mv "%" photo%
(renames 1.jpg to photo1.jpg)

7.  Add ssh identity to keychain

cd ~/.ssh
ssh -i myIdentity user@host

(brings up a password dialog, which offers an option to save the password in the keychain)

8.  Bash here-docs

cat <<EOF
hello,
world
EOF

9.  Customize bash prompt

export PS1=[\\h@\\w] in ~/.bash_login
gives you this prompt: [computer@~/Desktop]

10.  An overview of bash commands

http://www.ss64.com/bash/index.html

11.  Find keychain items via command line

security find-internet-password -s www.example.com -g 2>&1 >/dev/null

11.1  Example for reading an internet password with ruby:

result = `security find-internet-password -s www.domain.com -a user_account -g 2>&1 >/dev/null`
puts result[/password: "(.*)"/, 1]

12.  Put SSH Key on remote server

cat ~/.ssh/key.pub | ssh user@domain.com 'umask 077; cat >> .ssh/authorized_keys'

13.  Change hostname

sudo scutil --set HostName example.com

 
Zuletzt geändert am 20.05.2009 07:02 Uhr