-
Notifications
You must be signed in to change notification settings - Fork 6
/
.bash_osx
177 lines (149 loc) · 5.19 KB
/
.bash_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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
export BASH_SILENCE_DEPRECATION_WARNING=1
# edit this file
alias epo='vim ~/.bash_osx'
alias tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale"
# Color support for LS
export CLICOLOR=1
#
# Fields:
# directory
# symbolic link
# socket
# pipe
# executable
# block special
# character special
# executable with setuid bit set
# executable with setgid bit set
# directory writable to others, with sticky bit
# directory writable to others, without sticky bit
#
# Colors:
# a black
# b red
# c green
# d brown
# e blue
# f magenta
# g cyan
# h light grey
# A bold black, usually shows up as dark grey
# B bold red
# C bold green
# D bold brown, usually shows up as yellow
# E bold blue
# F bold magenta
# G bold cyan
# H bold light grey; looks like bright white
# x default foreground or background
#
#
export LSCOLORS=Exfxcxdxbxegedabagacad
# trash: Moves a file to the MacOS trash
trash () { command mv "$@" ~/.Trash ; }
# ql: Opens any file in MacOS Quicklook Preview
ql () { qlmanage -p "$*" >& /dev/null; }
# Build flags
if [[ $(uname -p) == 'i386' ]]; then
export ARCHFLAGS="-arch x86_64"
fi
# homebrew
if [[ $(uname -p) == 'arm' ]]; then
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
else
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
fi
# make sure Java8 is the defailt or some command line tools run slow.
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
# PG aliases
alias pg_start="pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start"
alias pg_stop="pg_ctl -D /usr/local/var/postgres stop -s -m fast"
# gtimeout is from coreutils - but they're all prefixed with g.
# I want the one that works like ubuntu :)
alias timeout='gtimeout'
# open simulator
alias iphonesim="open -a /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/"
# clean out the "open with" database
alias fixopenwith='/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user'
#node's bin in path
export PATH="/usr/local/share/npm/bin:$PATH"
# homedir/bin in path first
export PATH="$HOME/bin:$PATH"
#heroku
export PATH="$PATH:/usr/local/heroku/bin"
#go
export PATH="$PATH:$HOME/go/bin"
export GOPATH=$HOME/go
# Firefox profile
alias ffclean="/Applications/Firefox.app/Contents/MacOS/firefox-bin -P"
# cdf: 'Cd's to frontmost window of MacOS Finder
# ------------------------------------------------------
cdf () {
currFolderPath=$( /usr/bin/osascript <<EOT
tell application "Finder"
try
set currFolder to (folder of the front window as alias)
on error
set currFolder to (path to desktop folder as alias)
end try
POSIX path of currFolder
end tell
EOT
)
echo "cd to \"$currFolderPath\""
cd "$currFolderPath"
}
# ii: display useful host related informaton
# -------------------------------------------------------------------
ii() {
echo -e "\nYou are logged on ${RED}$HOST"
echo -e "\nAdditionnal information:$NC " ; uname -a
echo -e "\n${RED}Users logged on:$NC " ; w -h
echo -e "\n${RED}Current date :$NC " ; date
echo -e "\n${RED}Machine stats :$NC " ; uptime
echo -e "\n${RED}Current network location :$NC " ; scselect
echo -e "\n${RED}Public facing IP Address :$NC " ;myip
echo -e "\n${RED}DNS Configuration:$NC " ; scutil --dns
echo
}
term_720p() {
osascript -e 'tell application "iTerm2" to set the bounds of the front window to {24, 24, 1280, 720}'
}
term_1080p() {
osascript -e 'tell application "iTerm2" to set the bounds of the front window to {0, 0, 1922, 1104}'
}
# notify me when stuff is done
# use with ;
# some_command; notifyMe
notifyMe() {
RESULT_CODE=$?
if [ $RESULT_CODE -eq 0 ]; then
osascript -e 'display notification "The command worked" with title "Success"'
else
osascript -e 'display notification "The command failed" with title "Failed"'
fi
}
# aliases for starting/stopping yabai
alias yabaioff='yabai --stop-service'
alias yabaion='yabai --start-service'
alias yabairestart='yabai --restart-service'
# load gnu versions of utilities
if [[ $(uname -p) == 'arm' ]]; then
export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"
export PATH="/opt/homebrew/opt/findutils/libexec/gnubin:$PATH"
export PATH="/opt/homebrew/opt/gnu-sed/libexec/gnubin:$PATH"
export PATH="/opt/homebrew/opt/grep/libexec/gnubin:$PATH"
else
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
export PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH"
export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
fi
# quick command to see what's blocking keyboard input.
blocking() {
ioreg -l -w 0 \
| perl -nle 'print $1 if /"kCGSSessionSecureInputPID"=(\d+)/' \
| uniq \
| xargs -I{} ps -p {} -o comm=
}
alias flushdns="sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder"