-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy path.common_alias
130 lines (96 loc) · 4.04 KB
/
.common_alias
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
#!/bin/sh
alias ls='ls --color'
alias ll='ls -ahlF -t'
# verbose
alias mkdir='mkdir -v'
alias mv='mv -v'
alias cp='cp -v'
alias rm='rm -v'
alias ln='ln -v'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias git-tree='git log --graph --decorate --pretty=oneline --abbrev-commit'
alias p4="proxychains4"
# vim $(fzf)
alias vf='vim $(fzf --preview "file {}" --preview-window down:1 --inline-info)'
# open typora note
alias note="open -a typora /Users/laixintao/Program/gist"
alias cat="bat --plain --theme 'Monokai Extended' "
alias a=ansible
alias h=htop
alias d=docker
alias t=tmux
alias v=vagrant
alias ap=ansible-playbook
alias gpc='git pullrequest create $(git branch | grep \* | cut -d " " -f2) master'
alias gcn='git commit -v --no-verify'
alias gme='GIT_COMMITTER_DATE="$(gdate --date=20:43)"; git commit --date $GIT_COMMITTER_DATE' # private work
# find for hidden files
alias fd='fd -HI'
alias clean-log='\fd -HI -e log -x rm -rf'
# https://www.commandlinefu.com/commands/view/9065/what-is-the-use-of-this-switch-
function manswitch () { man $1 | less -p "^ +$2"; }
# convert milliseconds to verbose datetime
# https://stackoverflow.com/questions/12362562/convert-milliseconds-timestamp-to-date-from-unix-command-line
milliseconds() { echo $(date -d @$(($1 / 1000))) }
# alias iredis="/Users/laixintao/.virtualenvs/iredis/bin/iredis"
alias vg="vagrant global-status"
alias abrew="/opt/homebrew/bin/brew"
alias bfg="java -jar /Users/xintao.lai/Documents/jars/bfg-1.13.2.jar"
alias tmuxn="tmux new -s "
alias gtl='git log --tags --simplify-by-decoration --pretty="format:%ci %d"'
alias pocr='pngpaste - | tesseract stdin stdout'
alias mount-action-3='sudo mkdir /Volumes/dj-action-3 && sudo /sbin/mount_exfat /dev/disk2 /Volumes/dj-action-3/ && cd /Volumes/dj-action-3'
vh() {
echo "shutdown all Vagrant VMs..."
vagrant global-status | grep running | gawk '{print $1}' | xargs vagrant halt
}
alias prom-instance="pbpaste | promquery| xsv select instance | cut -d: -f 1"
% function xbin() {
command="$1"
args="${@:2}"
if [ -t 0 ]; then
curl -sS -X POST "https://xbin.io/${command}" -H "X-Args: ${args}"
else
curl -sS --data-binary @- "https://xbin.io/${command}" -H "X-Args: ${args}"
fi
}
% function lbin() {
command="$1"
args="${@:2}"
if [ -t 0 ]; then
curl -sS -X POST "http://localhost:6061/${command}" -H "X-Args: ${args}"
else
curl -sS --data-binary @- "http://localhost:6061/${command}" -H "X-Args: ${args}"
fi
}
% listening() {
if [ $# -eq 0 ]; then
sudo lsof -iTCP -sTCP:LISTEN -n -P
elif [ $# -eq 1 ]; then
sudo lsof -iTCP -sTCP:LISTEN -n -P | grep -i --color $1
else
echo "Usage: listening [pattern]"
fi
}
% function get_site_cert() {
domain=$1
echo | openssl s_client -showcerts -connect $domain:443 -servername $domain 2>/dev/null
}
% function download_site_cert_chain(){
openssl s_client -showcerts -verify 5 -connect $1:443 < /dev/null | \
awk '/BEGIN CERTIFICATE/,/END CERTIFICATE/{ if(/BEGIN CERTIFICATE/){a++}; out="cert"a".pem"; print >out}'
for cert in *.pem; do
newname=$(openssl x509 -noout -subject -in $cert | sed -nE 's/.*CN ?= ?(.*)/\1/; s/[ ,.*]/_/g; s/__/_/g; s/_-_/-/; s/^_//g;p' | tr '[:upper:]' '[:lower:]').pem
echo "${newname}"; mv "${cert}" "${newname}"
done
}
alias vimt="xargs -o vim -p"
alias p="pbpaste"
alias promquery-ip-toc-resource-node='pbpaste | promquery | xsv select instance | tail -n +2 | cut -d: -f 1 | tr -d " " | xargs -I {} bash -c "echo -n \"{} \"; server-inspect {} | rg \"Resource Node \""'
alias pytest="pytest --log-cli-level=DEBUG"
alias mount-canon="sudo rmdir -v /Volumes/canon ; sudo mkdir /Volumes/canon && sudo mount -t msdos /dev/disk2s1 /Volumes/canon"
alias reboot-foobar="vagrant halt 1c && vagrant up 1c"
alias sed="gsed"
alias rgip="rg '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' -o"