-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path50_osx.sh
56 lines (46 loc) · 1.79 KB
/
50_osx.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# OSX-only stuff. Abort if not OSX.
is_osx || return 1
# APPLE, Y U PUT /usr/bin B4 /usr/local/bin?!
PATH="/usr/local/bin:$(path_remove /usr/local/bin)"
export PATH
# This will enable Homebrew's bash-completion.
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
# Trim new lines and copy to clipboard
alias c="tr -d '\n' | pbcopy"
# Use GNU Tar
alias tar=gtar
# Make 'less' more.
[[ "$(type -P lesspipe.sh)" ]] && eval "$(lesspipe.sh)"
# Start ScreenSaver. This will lock the screen if locking is enabled.
alias ss="open /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app"
# Open finder to the current path.
alias finder='open /System/Library/CoreServices/Finder.app $PWD'
# After editing /etc/asl.conf
logReset() {
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist
sudo launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist
}
# Export Localization.prefPane text substitution rules.
function txt_sub_backup() {
local prefs=~/Library/Preferences/.GlobalPreferences.plist
local backup=$DOTFILES/conf/osx/NSUserReplacementItems.plist
/usr/libexec/PlistBuddy -x -c "Print NSUserReplacementItems" "$prefs" > "$backup" &&
echo "File ~${backup#$HOME} written."
}
# Import Localization.prefPane text substitution rules.
function txt_sub_restore() {
local prefs=~/Library/Preferences/.GlobalPreferences.plist
local backup=$DOTFILES/conf/osx/NSUserReplacementItems.plist
if [[ ! -e "$backup" ]]; then
echo "Error: file ~${backup#$HOME} does not exist!"
return 1
fi
cmds=(
"Delete NSUserReplacementItems"
"Add NSUserReplacementItems array"
"Merge '$backup' NSUserReplacementItems"
)
for cmd in "${cmds[@]}"; do /usr/libexec/PlistBuddy -c "$cmd" "$prefs"; done
}