Skip to content

Commit bceb49d

Browse files
committed
Normalize open across Linux, macOS, and Windows
This makes `o` work cross-platform as well. Also, delete some unused stuff from `.functions`.
1 parent b22c322 commit bceb49d

File tree

1 file changed

+9
-37
lines changed

1 file changed

+9
-37
lines changed

.functions

+9-37
Original file line numberDiff line numberDiff line change
@@ -102,30 +102,11 @@ function gz() {
102102
printf "gzip: %d bytes (%2.2f%%)\n" "$gzipsize" "$ratio";
103103
}
104104

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-
115105
# Run `dig` and display the most useful info
116106
function digga() {
117107
dig +nocmd "$1" any +multiline +noall +answer;
118108
}
119109

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-
129110
# Show all the names (CNs and SANs) listed in the SSL certificate
130111
# for a given domain
131112
function getcertnames() {
@@ -160,25 +141,16 @@ function getcertnames() {
160141
fi;
161142
}
162143

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';
178150
else
179-
vim "$@";
180-
fi;
181-
}
151+
alias open='xdg-open';
152+
fi
153+
fi
182154

183155
# `o` with no arguments opens the current directory, otherwise opens the given
184156
# location

0 commit comments

Comments
 (0)