-
Notifications
You must be signed in to change notification settings - Fork 0
/
.functions
33 lines (28 loc) · 899 Bytes
/
.functions
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
function md() {
mkdir -p "$@" && cd "$@"
}
function cs() {
cd $1
l
}
function f() {
find . -name "*$1*"
}
function path() {
PATH=$(pwd):$PATH
}
function o() {
local target="$@"
if [[ "$@" == "" ]]; then #no args
target="."
fi
[[ ${OSTYPE//[0-9.]/} == "darwin" ]] && open "$target"
[[ ${OSTYPE//[0-9.]/} == "linux-gnu" ]] && gnome-open "$target"
}
function server() {
local port="${1:-8000}"
open "http://localhost:${port}/"
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
}