REFERENCES FOR LEARNING & USING APPLESCRIPT Modified: 2018/06/19 18:47
AppleScript is a rather peculiar scripting language to learn.
| # use: | |
| # .bash_profile - only gets executed for login bash shells | |
| # .bashrc - only gets executed for NON-login bash shells for only NON-login shells | |
| # .profile - gets executed for ANY login shell | |
| # .bash_logout - only gets executed for bash shells after logout | |
| # Sets the prompt: | |
| #PS1='\h:\w \u\$ ' | |
| #PS2='> ' |
| # fix owner of files and folders recursively | |
| sudo chown -vR $(whoami) /usr/local /opt/homebrew-cask /Library/Caches/Homebrew | |
| # fix read/write permission of files and folders recursively | |
| chmod -vR ug+rw /usr/local /opt/homebrew-cask /Library/Caches/Homebrew | |
| # fix execute permission of folders recursively | |
| find /usr/local /opt/homebrew-cask /Library/Caches/Homebrew -type d -exec chmod -v ug+x {} + |
| tell application "Finder" | |
| set sel to the selection as text | |
| set fPath to quoted form of POSIX path of sel | |
| do shell script ("cat " & fPath & " | pbcopy && pbpaste") | |
| end tell |
| -- allSettings is a list of records containing {width:? height:? apps:{{name:? pos:? size:?},...} | |
| -- for each display setup store the apps and their associated position and size | |
| property allSettings : {} | |
| -- create a variable for the current settings | |
| set currentSettings to {} | |
| display dialog "Restore or save window settings?" buttons {"Restore", "Save"} default button "Restore" | |
| set dialogResult to result |
| #change some specific application's interface language | |
| defaults write com.google.Chrome AppleLanguages "(zh_CN,en_US)" | |
| defaults write com.apple.iWork.Pages AppleLanguages "(zh_CN,en_US)" | |
| defaults write com.apple.Aperture AppleLanguages "(zh_CN,en_US)" | |
| #change all applications' interface language, don't recommend. | |
| defaults write NSGlobalDomain AppleLanguages "(en_US,zh_CN)" | |
| defaults write NSGlobalDomain AppleLanguages "(zh_CN,en_US)" |
If you're doing stuff with Ruby on a Mac, e.g. installling Jekyll or something, by default you'll end up having to use the sudo command to do stuff, since the permission to modify the default config is not available to your user account.
This sucks and should be avoided. Here's how to fix that.
To make this better, we are going install a new, custom Ruby. This used to be a big, scary thing, but thanks to the awesome tools Homebrew and rbenv, it's a snap.*
A word of warning: you will have to use Terminal to install this stuff. If you are uncomfortable with text, words, and doing stuff with your computer beyond pointing and hoping, this may not work well for you. But if that's the case, I'm not sure why you were trying to use Ruby in the first place.
pyenv global
| ################################################################################ | |
| # PRIVACY RULES # | |
| # * OSX EL CAPITAN - NO CONNECTIONS TO CUPPERTINO * # | |
| # MIX OF DIFFERENT /etc/hosts FILES I'VE FOUND. 80% OF THE ENTRIES CAME FROM # | |
| # MY OWN. OSX SENDS HUGE AMMOUNT OF REQUESTS TO CUPPERTINO EVENT WHEN # | |
| # SPOTLIGHT SUGGESTIONS, ICLOUD, AND OTHER SERVICES ARE DISABLED # | |
| # USE IT IF YOU DON'T LIKE OSX CALLING HOME WHEN YOU DON'T WANT IT TO HAPPEN # | |
| # NO CONNECTIONS TO APPLE SERVERS REPORTED BY MY FIREWALL FOR 2 MONTHS # | |
| ################################################################################ | |
| # SAVED FROM: http://pastebin.com/GfaXGL4r |