@@ -102,30 +102,11 @@ function gz() {
102
102
printf " gzip: %d bytes (%2.2f%%)\n" " $gzipsize " " $ratio " ;
103
103
}
104
104
105
- # Syntax-highlight JSON strings or files
106
- # Usage: `json '{"foo":42}'` or `echo '{"foo":42}' | json`
107
- function json() {
108
- if [ -t 0 ]; then # argument
109
- python -mjson.tool <<< " $*" | pygmentize -l javascript;
110
- else # pipe
111
- python -mjson.tool | pygmentize -l javascript;
112
- fi ;
113
- }
114
-
115
105
# Run `dig` and display the most useful info
116
106
function digga() {
117
107
dig +nocmd " $1 " any +multiline +noall +answer;
118
108
}
119
109
120
- # UTF-8-encode a string of Unicode symbols
121
- function escape() {
122
- printf " \\ \x%s" $( printf " $@ " | xxd -p -c1 -u) ;
123
- # print a newline unless we’re piping the output to another program
124
- if [ -t 1 ]; then
125
- echo " " ; # newline
126
- fi ;
127
- }
128
-
129
110
# Show all the names (CNs and SANs) listed in the SSL certificate
130
111
# for a given domain
131
112
function getcertnames() {
@@ -160,25 +141,16 @@ function getcertnames() {
160
141
fi ;
161
142
}
162
143
163
- # `s` with no arguments opens the current directory in Sublime Text, otherwise
164
- # opens the given location
165
- function s() {
166
- if [ $# -eq 0 ]; then
167
- subl . ;
168
- else
169
- subl " $@ " ;
170
- fi ;
171
- }
172
-
173
- # `v` with no arguments opens the current directory in Vim, otherwise opens the
174
- # given location
175
- function v() {
176
- if [ $# -eq 0 ]; then
177
- vim . ;
144
+ # Normalize `open` across Linux, macOS, and Windows.
145
+ # This is needed to make the `o` function (see below) cross-platform.
146
+ if [ ! $( uname -s) = ' Darwin' ]; then
147
+ if grep -q Microsoft /proc/version; then
148
+ # Ubuntu on Windows using the Linux subsystem
149
+ alias open=' explorer.exe' ;
178
150
else
179
- vim " $@ " ;
180
- fi ;
181
- }
151
+ alias open= ' xdg-open ' ;
152
+ fi
153
+ fi
182
154
183
155
# `o` with no arguments opens the current directory, otherwise opens the given
184
156
# location
0 commit comments