-
Notifications
You must be signed in to change notification settings - Fork 5
/
.functions
44 lines (39 loc) · 1003 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
34
35
36
37
38
39
40
41
42
43
44
# DNS Records
function dighost() {
host $(dig $1 | grep ANSWER -C 1 | tail -n 1 | awk '{ print $5 }')
}
# Create a new directory and enter it
function cdmkdir() {
mkdir -p "$@" && cd "$@"
}
# Create a data URL from a file
function dataurl() {
local mimeType=$(file -b --mime-type "$1")
if [[ $mimeType == text/* ]]; then
mimeType="${mimeType};charset=utf-8"
fi
echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')"
}
# Git
# exports a git repo to a new project folder
git-export() {
if [ $# -lt 2 ]
then
echo "Error! Repo and project name required."
else
git clone --quiet --depth=1 $1 $2
rm -rf $2/.git*
fi
}
function pr() {
if [ $# -lt 1 ]
then
echo "Error! Missing Pull Request ID #."
else
git fetch origin refs/pull/$1/head:pull-request-$1;
git checkout pull-request-$1;
fi
}
function bgimage() {
osascript -e "tell application \"iTerm\" to set background image path of current session of current terminal to \"$1\""
}