-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.aliases
209 lines (152 loc) · 6.57 KB
/
.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!bash
# ------------------------------------------------------------------
# | Easier navigation: .., ..., ~ and - |
# ------------------------------------------------------------------
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ~="cd ~" # `cd` is probably faster to type though
alias -- -="cd -"
# ------------------------------------------------------------------
# | Typos |
# ------------------------------------------------------------------
alias cd..="cd .."
alias where=which # I always forget
alias brwe=brew
# ------------------------------------------------------------------
# | Directory Shortcuts |
# ------------------------------------------------------------------
# alias d="cd ~/Documents/Dropbox"
alias dl="cd ~/Downloads"
alias dt="cd ~/Desktop"
alias dc="cd ~/Documents"
# alias dv="cd ~/Development" #replaced with dv function in .functions
# ------------------------------------------------------------------
# | Application Shorthand |
# ------------------------------------------------------------------
alias g="git"
alias h="history"
alias j="jobs"
alias cls="clear"
alias cya="exit"
alias bye=cya
# ------------------------------------------------------------------
# | Modified Calls |
# ------------------------------------------------------------------
alias bc="bc -l" # Start calculator with math support
# Enable aliases to be sudo’ed
alias sudo="sudo "
alias please="sudo "
alias plz=please
## Colorize the grep command output for ease of use (good for log files)##
alias grep="grep --color=auto"
alias egrep="egrep --color=auto"
alias fgrep="fgrep --color=auto"
# Prettify mount command output
alias mount="mount |column -t"
alias rm="rm -i" # safety first
# ------------------------------------------------------------------
# | LS |
# ------------------------------------------------------------------
# use coreutils `ls` if possible…
hash gls >/dev/null 2>&1 || alias gls="ls"
# Detect which `ls` flavor is in use
if gls --color > /dev/null 2>&1; then # GNU `ls`
colorflag="--color"
else # OS X `ls`
colorflag="-G"
fi
# ls options: F = put `/` after folders, h = byte unit suffixes, color! (even with piping to awk)
alias ls="CLICOLOR_FORCE=1 gls -aFh ${colorflag} --group-directories-first"
# List ALL files (colorized() in long format, show permissions in octal
alias la="ls -l | awk '
{
k=0;
for (i=0;i<=8;i++)
k+=((substr(\$1,i+2,1)~/[rwx]/)*2^(8-i));
if (k)
printf(\"%0o \",k);
printf(\" %9s %3s %2s %5s %6s %s %s %s\n\", \$3, \$6, \$7, \$8, \$5, \$9,\$10, \$11);
}'"
# List all files colorized in long format
alias l="ls -lF ${colorflag}"
# List only directories
alias lsd="ls -l | grep '^d'"
# Count of all files in current dir
alias lsc='find . -type f -print0 | tr -d -c '\0' | echo -e "`wc -c $1` files in: `pwd`"'
# full paths version of ls
alias paths="find "$(pwd)" -maxdepth 1"
# ------------------------------------------------------------------
# | TIME / DATE |
# ------------------------------------------------------------------
# Get week number
alias week="date +%V"
# Gets a filename friendly date
alias fdate="date +%d_%m_%Y"
# Gets today's date
alias today="date +%d - %m - %Y"
# Get date formated for work
alias workdate="date +%d-%m-%y\ \ week:\ %V"
alias wdate="workdate"
# Stopwatch
alias timer="echo 'Timer started. Stop with Ctrl-D.' && date && time cat && date"
# Get Pay week number
alias payweek="expr `week` - 2"
alias pweek=payweek
# ------------------------------------------------------------------
# | IP |
# ------------------------------------------------------------------
# IP addresses
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en0"
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
# Enhanced WHOIS lookups
alias whois="whois -h whois-servers.net"
alias dig="dig +nocmd any +multiline +noall +answer"
# View HTTP traffic
alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""
# ------------------------------------------------------------------
# | MISC |
# ------------------------------------------------------------------
# `cat` with beautiful colors. requires Pygments installed.
# sudo easy_install -U Pygments
alias pcat='pygmentize -O style=native -f console256 -g'
# git root
alias gr='[ ! -z `git rev-parse --show-cdup` ] && cd `git rev-parse --show-cdup || pwd`'
alias croot=gr
# Recursively delete `.DS_Store` files
alias cleanup_dsstore="find . -name '*.DS_Store' -type f -ls -delete"
# Canonical hex dump; some systems have this symlinked
command -v hd > /dev/null || alias hd="hexdump -C"
# File size
alias fs="stat -f \"%z bytes\""
# Untar mumbo jumbo`
alias untar="tar -zxvf"
# Intuitive map function
# For example, to list all directories that contain a certain file:
# find . -name .gitattributes | map dirname
alias map="xargs -n1"
# URL-encode strings
alias urlencode="python -c 'import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);'"
# ------------------------------------------------------------------
# | FUN |
# ------------------------------------------------------------------
# undending stream of randomness for haxoring
alias haxor="hd -C < /dev/urandom | grep 'ca fe'"
# ROT13-encode text. Works for decoding, too! ;)
alias rot13="tr a-zA-Z n-za-mN-ZA-M"
# # One of @janmoesen’s ProTip™s
# # Using Httpie for now
# for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
# alias "$method"="lwp-request -m '$method'"
# done
# ------------------------------------------------------------------
# | OSX |
# ------------------------------------------------------------------
source ~/.aliasesOSX
# ------------------------------------------------------------------
# | Ubuntu |
# ------------------------------------------------------------------
source ~/.aliasesUbuntu