New aliases.
This commit is contained in:
parent
dba85e7026
commit
fdeddfd658
@ -76,3 +76,5 @@ ginit() { grunt init:$@ ;}
|
|||||||
|
|
||||||
# Load external aliases
|
# Load external aliases
|
||||||
source ~/dotfiles/includes/root.sh
|
source ~/dotfiles/includes/root.sh
|
||||||
|
source ~/dotfiles/includes/functions.sh
|
||||||
|
|
36
includes/functions.sh
Normal file
36
includes/functions.sh
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# Create a new directory and enter it
|
||||||
|
function mkd() {
|
||||||
|
mkdir -p "$@" && cd "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get gzipped file size
|
||||||
|
function gz() {
|
||||||
|
echo "Original size (bytes): "
|
||||||
|
cat "$1" | wc -c
|
||||||
|
echo "Gzipped size (bytes): "
|
||||||
|
gzip -c "$1" | wc -c
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Escape UTF-8 characters into their 3-byte format
|
||||||
|
function escape() {
|
||||||
|
printf "\\\x%s" $(printf "$@" | xxd -p -c1 -u)
|
||||||
|
echo # newline
|
||||||
|
}
|
||||||
|
|
||||||
|
# Decode \x{ABCD}-style Unicode escape sequences
|
||||||
|
function unidecode() {
|
||||||
|
perl -e "binmode(STDOUT, ':utf8'); print \"$@\""
|
||||||
|
echo # newline
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get a character’s Unicode code point
|
||||||
|
function codepoint() {
|
||||||
|
perl -e "use utf8; print sprintf('U+%04X', ord(\"$@\"))"
|
||||||
|
echo # newline
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user