-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.shell_functions
82 lines (67 loc) · 1.75 KB
/
.shell_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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
function download_all_user_repos {
API_URL="https://api.github.com/users/$1/repos"
for url in $(curl -s $API_URL | jq -r '.[].html_url')
do
git clone $url $1/${url##*/}
done
}
function get_process_for_port {
if [[ -z $1 ]]; then
echo "Please specify port to check"
return
fi
lsof -nP -iTCP:$1
}
function gi { curl -L -s https://www.gitignore.io/api/$@ ; }
function git_untracked_local_branches_show {
git branch --format "%(refname:short) %(upstream)"
}
function pprint_csv {
# pretty print csv files
csvlook "$1" | less -#2 -N -S
}
function pprint_json {
# pretty print json files
cat "$1" | python -m json.tool | less -i
}
function pprint_xml {
cat "$1" | xmllint --format - 2>&1 | less -i
}
function s3_path_size {
aws s3 ls --summarize --human-readable --recursive $*
}
function strip_comments_blank_lines {
if [ $# -eq 0 ]; then
\grep -v -E "\s*#|^\s*$" </dev/stdin
else
\grep -v -E "\s*#|^\s*$" "$*"
fi
}
function sync_emulator_time {
adb -e shell su root date `date +"%m%d%H%M%y"`
}
# ---------- linux apt
function install_package {
set -eu
(
export TEMP_PKG_INSTALL_FILE="$(mktemp)"
(
wget -O "$TEMP_PKG_INSTALL_FILE" "$1" &&
sudo dpkg --skip-same-version -i "$TEMP_PKG_INSTALL_FILE"
)
rm -f "$TEMP_PKG_INSTALL_FILE"
)
}
# ---------- macos
function divvy_export {
if [[ $1 == "" ]]; then
echo "Please provide filename to write divvy config to"
else
open -a Safari divvy://export && (pbpaste > "$1")
fi
}
function clear_macos_timemachine_snapshots {
for curr_dir in $(tmutil listlocalsnapshotdates | grep "-"); do
sudo tmutil deletelocalsnapshots $curr_dir
done
}