-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zsh_aliases
132 lines (102 loc) · 2.99 KB
/
.zsh_aliases
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
###########
# Aliases #
# for macOS, overwrite default ls with gls
# whichever ls you end up with; enable colours
2>&1 >/dev/null which gls && \
alias ls="gls --color=auto" || \
alias ls="ls --color=auto"
alias cdw='cd ~/workspace'
v() {
nvim "$@"
}
# common tpyos
alias claer='clear'
alias gti='git'
alias ll="ls -lFh"
alias la="ll -A"
alias path='echo -e ${PATH//:/\\n}'
alias alert="osascript -e 'display notification \"Your thing is done\" with title \"alert\"'"
alias stripcol="perl -pi -e 's/\\x1b\\[[0-9;]*m//g'"
npu() {
[ -f .nvmrc ] && nvm exec npm "$@" || npm "$@"
}
nodu() {
[ -f .nvmrc ] && nvm exec node "$@" || node "$@"
}
bs() {
BROWSERS="firefox:safari:Google Chrome:opera"
for b in ${(s.:.)BROWSERS}; do open -a $b $1; done
}
alias uuidlower="uuidgen | tr '[:upper:]' '[:lower:]'"
runfrom() {
( cd $1 && "${@:2}" )
}
serve() {
runfrom ${1:-"."} python3 -m http.server --bind 127.0.0.1
}
# sometimes you want to run a localhost server with create-react-app which
# enforces CORS rules 😠 but the swiss army snake saves the day
servecors() {
echo "Running on https://localhost.bbc.co.uk:7080/"
runfrom ${1:-"."} python3 <<EOP
import http.server
class CORSRequestHandler(http.server.SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')
http.server.SimpleHTTPRequestHandler.end_headers(self)
server_address = ('localhost', 7080)
httpd = http.server.HTTPServer(server_address, CORSRequestHandler)
httpd.serve_forever()
EOP
}
alias rot13="tr 'A-Za-z' 'N-ZA-Mn-za-m' <<<"
alias urlencode="node -e 'console.log(encodeURIComponent(require(\"fs\").readFileSync(0, \"utf-8\")))'"
alias urldecode="node -e 'console.log(decodeURIComponent(require(\"fs\").readFileSync(0, \"utf-8\")))'"
function slesc {
echo $1 | sed -e 's/\//\\\//g'
}
# passes file found with fuzzy-find as last argument in rest of command
# e.g. `f vim` to find a file to edit with vim
# `f git add` to find a file to stage in git
# probably breaks on filenames with quotes 😬
f () {
if 2>&1 >/dev/null which fzf; then
"$@" "$(fzf)"
else
fzf # just print the usual command is not installed error
fi
}
[ -e "$HOME/.config/awesome/rc.lua" ] && alias awcon="vim $HOME/.config/awesome/rc.lua"
alias cfg='git --git-dir=$HOME/.cfg --work-tree=$HOME'
alias sc="jq .scripts package.json"
note () {
if [[ -z "$@" ]]
then
return 1
fi
echo "$(date)\n""$@\n" >> ~/notefile
}
alias notes="v ~/notefile"
alias todo="v ~/todofile"
if >/dev/null command -v exa; then
alias l="exa --long --header --git"
fi
alias pregpg="echo 123 | gpg --clearsign -o -"
sbt() {
if 2>/dev/null >/dev/null stat ./build.sbt || [[ "$1" = "new" ]] ; then
command sbt "$@"
else
echo "this doesn't look like an sbt project. are you in the right dir?"
return 1
fi
}
sbtc() {
local args=";"
for x in $@; do
args+="$x;"
done
sbt -client "$args"
}
rand_str() {
openssl rand 200 | LC_ALL=C tr -dc 'A-Za-z0-9!"#$%&()*+,/:;<=>?@[]^_{|}~' | head -c ${1:-20}
}