-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path.osx
executable file
·98 lines (81 loc) · 3.34 KB
/
.osx
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#
# Contains scripts applicable to Mac OSX
#
# ---[ exports ]---------------------------------------------------------
# Install GNU core utilities (those that come with OS X are outdated)
# brew install coreutils
# All commands have been installed with the prefix 'g'.
# If you really need to use these commands with their normal names, you
# can add a "gnubin" directory to your PATH from your bashrc like:
# PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"
# So here is it!
# http://www.gnu.org/software/coreutils/manual/html_node/index.html
export PATH=$(brew --prefix coreutils)/libexec/gnubin:$PATH
export PATH=$(brew --prefix findutils)/libexec/gnubin:$PATH
export PATH=$(brew --prefix gnu-sed)/libexec/gnubin:$PATH
export PATH=$(brew --prefix grep)/libexec/gnubin:$PATH
export PATH=$(brew --prefix curl)/bin:$PATH
# ---[ aliases ]---------------------------------------------------------
alias o="open"
alias oo="open ."
# Lock screen
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
# add a poor facsimile for Linux's `free` if we're on Mac OS
if ! type free > /dev/null 2>&1 && [[ "$(uname -s)" == 'Darwin' ]]
then
alias free="top -s 0 -l 1 -pid 0 -stats pid | grep '^PhysMem: ' | cut -d : -f 2- | tr ',' '\n'"
fi
# requires github.com/dronir/SpotifyControl
alias spotify="osascript ~/bin/SpotifyControl/SpotifyControl.scpt"
# Get OS X Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages
alias update='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; npm install npm -g; npm update -g; sudo gem update'
# Empty the Trash on all mounted volumes and the main HDD
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; rm -rfv ~/.Trash"
# Hide/show all desktop icons (useful when presenting)
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
# Hide/Show hidden files in Finder
alias hidehiddenfiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
alias showhiddenfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
# ---[ functions ]---------------------------------------------------------
# Change working directory to the top-most Finder window location
function cdf() { # short for `cdfinder`
cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')"
}
# Add note to Notes.app (OS X 10.8)
# Usage: `note 'foo'` or `echo 'foo' | note`
function note() {
local text
if [ -t 0 ]; then # argument
text="$1"
else # pipe
text=$(cat)
fi
body=$(echo "$text" | sed -E 's|$|<br>|g')
osascript >/dev/null <<EOF
tell application "Notes"
tell account "iCloud"
tell folder "Notes"
make new note with properties {name:"$text", body:"$body"}
end tell
end tell
end tell
EOF
}
# Add reminder to Reminders.app (OS X 10.8)
# Usage: `remind 'foo'` or `echo 'foo' | remind`
function remind() {
local text
if [ -t 0 ]; then
text="$1" # argument
else
text=$(cat) # pipe
fi
osascript >/dev/null <<EOF
tell application "Reminders"
tell the default list
make new reminder with properties {name:"$text"}
end tell
end tell
EOF
}