-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.functions
46 lines (41 loc) · 924 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
45
46
#!/usr/bin/env zsh
# Create a new directory and enter it
function mkd() {
if [ ! -n "$1" ]; then
echo "Usage: $0 <dir name>"
return
fi
mkdir -p "$1" && cd "$1" || exit
}
# Get only http status code from curl
function status() {
if [ -z "${1}" ]; then
echo "You forgot the url dude..."
exit 1
fi
curl -s -o /dev/null -w "%{http_code}" ${1} | sed s/%//g
}
# Determine size of a file or total size of a directory
function fs() {
if du -b /dev/null > /dev/null 2>&1; then
local arg=-sbh;
else
local arg=-sh;
fi
if [[ -n "$@" ]]; then
du $arg -- "$@";
else
du $arg .[^.]* ./*;
fi;
}
# Select a specific toolbox in ~/.bin
function toolbox() {
local toolbox="${1}"
export ACTIVE_TOOLBOX=${toolbox}
if [[ -d "$HOME/.bin/$toolbox" ]]; then
export PATH="$PATH:$HOME/.bin/$toolbox"
fi
if [[ -f "${HOME}/.${toolbox}.inc" ]]; then
source "${HOME}/.${toolbox}.inc"
fi
}