-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.shell_functions.fish
90 lines (71 loc) · 2.19 KB
/
.shell_functions.fish
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
83
84
85
86
87
88
89
90
function download_all_user_repos
set GITHUB_USER $argv[1]
set API_URL "https://api.github.com/users/$GITHUB_USER/repos"
for url in (curl -s $API_URL | jq -r '.[].html_url')
git clone $url $GITHUB_USER/(string match -r '.*\/(.*)' "$url" | tail -n 1)
end
end
function google_chrome_no_security
open -na Google\ Chrome --args --user-data-dir=/tmp/temporary-chrome-profile-dir \
--disable-web-security --disable-site-isolation-trials
end
function get_process_for_port
# TODO: only works on linux currently
if test -z "$argv"
echo "Please specify port to check"
return
end
lsof -nP -iTCP:$argv
end
function gi
curl -L -s https://www.gitignore.io/api/$argv
end
function git_untracked_local_branches_show
git branch --format "%(refname:short) %(upstream)"
end
function kll
eval kail (k get pods | grep "$argv[1]" | cut -d" " -f1 | sd -- '(?P<pod>.*)\n' '--pod $pod ') $argv[2..-1]
end
function pprint_csv
# pretty print csv files
csvlook "$argv" | less -#2 -N -S
end
function pprint_json
# pretty print json files
cat $argv | python -m json.tool | less -i
end
function pprint_xml
cat $argv | xmllint --format - 2>&1 | less -i
end
function profile_shell
fish --profile-startup /tmp/profile -c fish_prompt; sort -nk2 /tmp/profile
end
function s3_path_size
aws s3 ls --summarize --human-readable --recursive $argv
end
function strip_comments_blank_lines
\grep -v -E "\s*#|^\s*\$" "$argv"
end
function sync_emulator_time
adb -e shell su root date `date +"%m%d%H%M%y"`
end
# ---------- linux apt
function install_package
set TEMP_PKG_INSTALL_FILE (mktemp)
wget -O "$TEMP_PKG_INSTALL_FILE" "$argv" && sudo dpkg --skip-same-version -i "$TEMP_PKG_INSTALL_FILE" || true
rm -f "$TEMP_PKG_INSTALL_FILE"
set --erase TEMP_PKG_INSTALL_FILE
end
# ---------- macos
function divvy_export
if test -z $argv
echo "Please provide filename to write divvy config to"
else
open -a Safari divvy://export && pbpaste > "$argv"
end
end
function clear_macos_timemachine_snapshots
for curr_dir in (tmutil listlocalsnapshotdates | grep "-")
sudo tmutil deletelocalsnapshots $curr_dir
end
end