-
Notifications
You must be signed in to change notification settings - Fork 0
/
zshextra
105 lines (97 loc) · 4.08 KB
/
zshextra
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
# Better mv
autoload -U zmv
# Aliases
alias au='sudo apt update'
alias ag='sudo apt upgrade'
alias ap='sudo apt purge'
alias al='apt list --upgradeable'
alias ai='sudo apt install'
alias aac='sudo apt autoclean'
alias aar='sudo apt autoremove'
alias asc='apt search'
alias asw='apt show'
alias v='vim'
alias n='nvim'
alias sudo='sudo -E'
# link ncurses
alias ccu='clang -lncurses'
# force c++11 standard and take no guff
alias c11='clang++ -std=c++11 -Wno-tautological-compare'
# because a lot of servers don't have terminfo for urxvt-256
alias xssh='TERM=xterm ssh'
alias lisp='/usr/bin/gcl'
# List only the directories
alias lsd="ls --color=always -lF | grep --color=never '^d'"
alias lsda="ls --color=always -lFA | grep --color=never '^d'"
# List only the files
alias lsf="ls --color=always -lF | grep --color=never '^-'"
alias lsfa="ls --color=always -lFA | grep --color=never '^-'"
# Fast ping
alias p='ping -c 100 -i.2'
# show $PATH as a list (Human readable)
alias path='echo -e ${PATH//:/\\n}'
# simple dates
alias now='date +"%T"'
alias day='date +"%a %x"'
# Get web server headers and see if gzip/mod_deflate is supported
alias header='curl -I'
alias headerc='curl -I --compress'
# Get SSL cert info
alias sslconnect='openssl s_client -connect'
# Hostname lookup on ip range
alias nmsl='nmap -sL'
# Full discovery scan
alias disco='sudo nmap -sS -sU -T4 -A -v -PE -PP -PS80,443 -PA3389 -PU40125 -PY -g 53 --script "default or (discovery and safe)"'
# Safety nets
alias rm='rm -I --preserve-root'
alias mv='mv -iv'
alias cp='cp -iv'
alias ln='ln -iv'
alias chown='chown -v --preserve-root'
alias chmod='chmod -v --preserve-root'
alias chgrp='chgrp -v --preserve-root'
# Alt-s inserts sudo at the start of the line
insert_sudo () { zle beginning-of-line; zle -U "sudo " }
zle -N insert-sudo insert_sudo
bindkey "^[s" insert-sudo
# Open $file in $EDITOR if $file has certain suffix
_editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex md)
for ft in $_editor_fts ; do alias -s $ft=$EDITOR ; done
# If I want a julia repl - use docker
alias julia='docker run --rm -it -u $(id -u):$(id -g) -w /data -e "HOME=$HOME" -v "$HOME:$HOME" -v "$PWD":/data julia'
# Wren REPL
alias wren='docker run --rm -it -u $(id -u):$(id -g) -v "$PWD":/tmp -w /tmp ajpaulson/wren'
# python2 Clean env
alias p2='docker run --rm -it -w /data -e "HOME=$HOME" -v "$HOME:$HOME" -v "$PWD":/data python:2-alpine'
# python3 Clean env
alias p3='docker run --rm -it -w /data -e "HOME=$HOME" -v "$HOME:$HOME" -v "$PWD":/data python:alpine'
# python3 ptpython
alias ptpy='docker run --rm -it -w /data -e "HOME=$HOME" -v "$HOME:$HOME" -v "$PWD":/data ajpaulson/ptpy'
alias ptpy-ff='docker run --rm -it -w /data -e "HOME=$HOME" -v "$HOME:$HOME" -v "$PWD":/data ajpaulson/ptpy:full-fat'
# golang
alias golang='docker run --rm -it -w /data -e "HOME=$HOME" -v "$HOME:$HOME" -v "$PWD":/data golang:alpine'
# gimme a debian docker container:
alias debdock='docker run --rm -it -w /data -v "$HOME/.ssh:/root/.ssh" -v "$HOME=$HOME" -v "$PWD:/data" debian:stable bash'
# replace terraform
# alias terraform='docker run --rm -it -w /data -v "$HOME/.ssh:/root/.ssh" -v "$HOME/.aws:/root/.aws" -v "$PWD:/data" hashicorp/terraform'
# Docker refresh and cleanup images
alias freshdock='docker images --format "{{.Repository}}:{{.Tag}}" -f dangling=false | xargs -L1 docker pull'
alias cleandock='docker images --format "{{.ID}}" -f dangling=true | xargs -L1 docker rmi'
alias killdock='docker ps -a --format "{{.Names}}" | xargs -L1 docker rm'
# Simple ZSH builtin calculator
calc() { echo $(( $* )) }
# don't glob that!
alias calc='noglob calc'
# urandom can rock a beat
dednes () {
cat /dev/urandom | hexdump -v -e '/1 "%u\n"' | \
awk '{ split("0,2,4,5,7,9,11,12",a,","); for (i = 0; i < 1; i+= 0.0001) \
printf("%08X\n", 100*sin(1382*exp((a[$1 % 8]/12)*log(2))*i)) }' | \
xxd -r -p | aplay -c 2 -f S32_LE -r 16000;
}
macnes () {
cat /dev/urandom | hexdump -v -e '/1 "%u\n"' | \
awk '{ split("0,2,4,5,7,9,11,12",a,","); for (i = 0; i < 1; i+= 0.0001) \
printf("%08X\n", 100*sin(1382*exp((a[$1 % 8]/12)*log(2))*i)) }' | \
xxd -r -p | sox -traw -c 2 -v 0.25 -r8000 -b32 -e signed-integer - -tcoreaudio;
}