-
-
Notifications
You must be signed in to change notification settings - Fork 92
/
.zsh_aliases
167 lines (138 loc) · 4.63 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/usr/bin/env zsh
#
# Only including a shebang to trigger editors to use shell syntax highlighting
#
# Copyright 2006-2021 Joseph Block <jpb@unixorn.net>
#
# BSD licensed, see LICENSE.txt in this repository.
if [[ -d ~/gocode ]]; then
export GOPATH=~/gocode
fi
# Sublime
if [[ -x /usr/local/bin/subl ]]; then
alias s="subl"
fi
# Yes, these tests are ugly. They do however, work.
if [[ "$(uname -s)" == "Darwin" ]]; then
# do macOS specific things
alias top="TERM=vt100 top"
else
alias cputop="top -o cpu"
alias l-d="ls -lad"
alias l="ls -lah"
alias ll="ls -lah | less"
fi
if [[ "$(uname -s)" == "Linux" ]]; then
# we're on linux
alias l-d="ls -lFad"
alias l="ls -laF"
alias ll="ls -lFa | TERM=vt100 less"
fi
# Set up colorized ls when gls is present - it's installed by grc
# shellcheck disable=SC2154
if (( $+commands[gls] )); then
alias ls="gls -F --color"
alias l="gls -lAh --color"
alias ll="gls -l --color"
alias la='gls -A --color'
fi
export CVS_RSH=ssh
# shellcheck disable=SC2142
alias historysummary="history | awk '{a[\$2]++} END{for(i in a){printf \"%5d\t%s\n\",a[i],i}}' | sort -rn | head"
if [ -x /bin/vim ]; then
alias vi="/bin/vim"
alias vim="/bin/vim"
export EDITOR="/bin/vim"
fi
if [ -x /usr/bin/vim ]; then
alias vi="/usr/bin/vim"
alias vim="/usr/bin/vim"
export EDITOR="/usr/bin/vim"
fi
# MacPorts has a newer vim than Apple ships
if [ -x /opt/local/bin/vim ]; then
alias vim="/opt/local/bin/vim"
alias vi="/opt/local/bin/vim"
export EDITOR="/opt/local/bin/vim"
fi
# So does brew
if [ -x /usr/local/bin/vim ]; then
alias vim="/usr/local/bin/vim"
alias vi="/usr/local/bin/vim"
export EDITOR="/usr/local/bin/vim"
fi
# Clearly, I really like vim.
export VISUAL=${EDITOR}
# Clean up files that have the wrong line endings
alias mac2unix="tr '\015' '\012'"
alias unix2mac="tr '\012' '\015'"
# A couple of different external IP lookups depending on which is down.
alias external_ip="curl -s icanhazip.com"
alias myip="dig +short myip.opendns.com @resolver1.opendns.com"
# Show laptop's IP addresses
# shellcheck disable=2139
alias ips="ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1'"
alias reattach="screen -r"
# SSH stuff
# Pass our credentials by default
alias ssh='ssh -A'
alias sshA='ssh -A'
alias ssh-A='ssh -A'
alias ssh-unkeyed='/usr/bin/ssh'
alias ssh_unkeyed='/usr/bin/ssh'
alias scp-no-hostchecks='scp -o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
alias ssh-no-hostchecks='ssh -A -o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
alias scp_no_hostchecks='scp -o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
alias ssh_no_hostchecks='ssh -A -o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
# Set up even more shortcuts because I am that lazy a typist.
alias nh-scp=scp-no-hostchecks
alias nh-ssh=ssh-no-hostchecks
alias nh_scp=scp-no-hostchecks
alias nh_ssh=ssh-no-hostchecks
alias nhscp=scp-no-hostchecks
alias nhssh=ssh-no-hostchecks
# Strip color codes from commands that insist on spewing them so we can
# pipe them into files cleanly.
alias stripcolors='sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g"'
# On the rare occasions I don't want to continue an interrupted download
# I can always delete the incomplete fragment explicitly. I usually just
# want to complete it.
alias wget="wget -c"
# Dump the last 20 history entries to make !number more convenient to use.
alias zh="fc -l -d -D"
# My typical tyops.
alias gerp='grep'
alias grep-i='grep -i'
alias grep='GREP_COLOR="1;37;41" LANG=C grep --color=auto'
alias grepi='grep -i'
alias knfie='knife'
alias maek='make'
alias psax='ps ax'
alias pswax='ps wax'
alias psxa='ps ax'
alias raek='rake'
alias tartvf='tar tvf'
alias tartvzf='tar tvzf'
alias tarxvf='tar xvf'
# Deal with various stupidities.
# Thanks so much for breaking ldapsearch, fink
if [ -x /sw/bin/ldapsearch ];then
# At least the stale version Apple ships actually works.
alias ldapsearch=/usr/bin/ldapsearch
fi
# Use brew versions if present
if [ -x /usr/local/bin/mysql/bin/mysql ]; then
alias mysql="/usr/local/mysql/bin/mysql"
fi
if [ -x /usr/local/bin/mysql/bin/mysqladmin ]; then
alias mysqladmin="/usr/local/mysql/bin/mysqladmin"
fi
# Help the lazy typists again.
alias ..="cd .."
alias ...="cd ../.."
# Honor old .zsh_aliases.local customizations, but print depecation warning.
if [ -f ~/.zsh_aliases.local ]; then
# shellcheck disable=SC1090
source ~/.zsh_aliases.local
echo ".zsh_aliases.local is deprecated. Make entries in files in ~/.zshrc.d instead."
fi