-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.functions
61 lines (47 loc) · 1.88 KB
/
.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
# Custom functions
function download () {
cd ~/Downloads && { curl -O -C - "$1" ; cd -; }
}
function gi() { curl -fL https://www.gitignore.io/api/${(j:,:)@} }
function change-version() {
tmp=$(mktemp)
jq --arg VERSION "$1" '.version = $VERSION' package.json > "$tmp" && mv "$tmp" package.json
}
# CheatSheet
cht() { curl cht.sh/$1 }
# PROJECTS
cdd() {
if [ -n "$1" ]
then
cd ~/code/$1
else
cd ~/code
fi
}
mg () { mkdir "$@" && cd "$@" || exit; }
npm-latest() { npm info "$1" | grep latest; }
weather() { curl "http://wttr.in/$1\?lang\=es"; }
function qr { curl qrcode.show/$@; }
# Filebot
function fbmovie { filebot -rename -r ./$@ --file-filter f.video --db TheMovieDB --format {ny}/{ny}{' CD'+pi}{subt} --output /Volumes/Movies; }
function fbserie { filebot -rename -r ./$@ --file-filter f.video --db TheTVDB --format "{n}/{'Season '+s}/{s00e00} - {t}" --output /Volumes/Series; }
### Functions for setting and getting environment variables from the OSX keychain ###
### Adapted from https://www.netmeister.org/blog/keychain-passwords.html ###
# Use: keychain-environment-variable SECRET_ENV_VAR
function keychain-environment-variable () {
security find-generic-password -w -a ${USER} -D "environment variable" -s "${1}"
}
# Use: set-keychain-environment-variable SECRET_ENV_VAR
# provide: super_secret_key_abc123
function set-keychain-environment-variable () {
[ -n "$1" ] || print "Missing environment variable name"
# Note: if using bash, use `-p` to indicate a prompt string, rather than the leading `?`
read -s "?Enter Value for ${1}: " secret
( [ -n "$1" ] && [ -n "$secret" ] ) || return 1
security add-generic-password -U -a ${USER} -D "environment variable" -s "${1}" -w "${secret}"
}
### Update ZSH theme
function zsh-update-theme () {
git -C $ZSH_CUSTOM/themes/$ZSH_THEME fetch -p
git -C $ZSH_CUSTOM/themes/$ZSH_THEME pull
}