forked from mathiasbynens/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.functions
32 lines (27 loc) · 963 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
# Create a new directory and enter it
function md() {
mkdir -p "$@" && cd "$@"
}
# Test if HTTP compression (RFC 2616 + SDCH) is enabled for a given URL.
# Send a fake UA string for sites that sniff it instead of using the Accept-Encoding header. (Looking at you, ajax.googleapis.com!)
function httpcompression() {
encoding="$(curl -LIs -H 'User-Agent: Mozilla/5 Gecko' -H 'Accept-Encoding: gzip,deflate,compress,sdch' "$1" | grep '^Content-Encoding:')" && echo "$1 is encoded using ${encoding#* }" || echo "$1 is not using any encoding"
}
function json() {
python -mjson.tool <<< "$*" | pygmentize -l javascript
}
# All the dig info
function digga() {
dig +nocmd "$1" any +multiline +noall +answer
}
function add_alias() {
COMMAND="$1"
ALIAS_NAME="$2"
NEW_ALIAS_COMMAND="alias $2=\"$1\""
echo "$NEW_ALIAS_COMMAND" >> ~/.aliases
source ~/.bash_profile
echo "New alias: $NEW_ALIAS_COMMAND"
}
function bookmark() {
add_alias "cd $(pwd)" "$1"
}