1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | alias fixcamera="sudo killall VDCAssistant"
|
9 |
|
10 | alias ipin="ipconfig getifaddr en0"
|
11 |
|
12 | alias ipout='dig +short myip.opendns.com @resolver1.opendns.com'
|
13 |
|
14 | alias ip="echo -e Internal IP Address: ; ipconfig getifaddr en0; echo -e Public facing IP Address: ; curl ipecho.net/plain ; echo ;"
|
15 | alias aliases='alias'
|
16 | alias ..='cd ..'
|
17 | alias cd..='cd ..'
|
18 | alias .2="cd ../../"
|
19 | alias .3="cd ../../../"
|
20 | alias .4="cd ../../../../"
|
21 | alias .5="cd ../../../../../"
|
22 | alias .6="cd ../../../../../../"
|
23 | alias .7="cd ../../../../../../../"
|
24 | alias ll='ls -FGlAhp'
|
25 | alias ls='ls -FA'
|
26 | alias ~="cd ~"
|
27 | alias root="cd /"
|
28 | alias www="cd /var/www/"
|
29 | alias commit="git commit -a"
|
30 | alias commitAll="git add -A; git commit -a"
|
31 | alias gitlog="git log --graph --decorate --oneline"
|
32 | alias gittree="git log --graph --decorate --oneline --all"
|
33 | alias checkout="git checkout"
|
34 |
|
35 | function bold () {
|
36 | echo "$(tput bold)$@$(tput sgr0)"
|
37 | }
|
38 | alias bold="bold"
|
39 |
|
40 | alias push="git push origin"
|
41 | alias pull="git pull origin"
|
42 | alias exit="exit && echo 0 > ~/.uis"
|
43 | alias line="printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -"
|
44 | alias doubleline="printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' ="
|
45 | alias sizes="sudo du -cxhd 1"
|
46 | alias flushDNS='dscacheutil -flushcache'
|
47 | alias DSFiles_removal="find . -type f -name '*.DS_Store' -ls -delete"
|
48 | alias hosts_edit='sudo vim /etc/hosts'
|
49 | alias reloadprofiler='source ~/.bash_profile'
|
50 | alias reload="exec ${SHELL} -l"
|
51 |
|
52 | alias h='history'
|
53 | alias today='date +"%d-%m-%Y"'
|
54 | alias now='date +"%T"'
|
55 | alias ports='netstat -tulanp'
|
56 | alias lsd='ll | grep "^d" --colors=never'
|
57 | alias lsf='ll | grep "^[^d]" --color=no'
|
58 | alias grep='grep --color=auto'
|
59 | alias fgrep='fgrep --color=auto'
|
60 | alias egrep='egrep --color=auto'
|
61 |
|
62 | alias desktop='cd ~/Desktop'
|
63 | alias desk='cd ~/Desktop'
|
64 | alias d='cd ~/Documents'
|
65 | alias docs='cd ~/Documents'
|
66 | alias documents='cd ~/Documents'
|
67 | alias downloads='cd ~/Downloads'
|
68 | alias down='cd ~/Downloads'
|
69 | alias amionline="ping www.google.com -t 1 2>/dev/null >/dev/null && echo \"Yes\" || echo \"No\""
|
70 | alias amioffline="ping www.google.com -t 1 2>/dev/null >/dev/null && echo \"No\" || echo \"Yes\""
|
71 |
|
72 | alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'"
|
73 | alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder"
|
74 | command -v md5sum > /dev/null || alias md5sum="md5"
|
75 | command -v sha1sum > /dev/null || alias sha1sum="shasum"
|
76 |
|
77 | function dog () {
|
78 | cat $@ | less -FRNX
|
79 | }
|
80 |
|
81 |
|
82 | alias show-hidden-files="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
|
83 | alias hide-hidden-files="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
|
84 |
|
85 |
|
86 |
|
87 |
|
88 | alias path='echo -e ${PATH//:/\\n}'
|
89 |
|
90 | alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
|
91 |
|
92 |
|
93 | alias chromekill="ps ux | grep '[C]hrome Helper --type=renderer' | grep -v extension-process | tr -s ' ' | cut -d ' ' -f2 | xargs kill"
|
94 |
|
95 | alias hide-desktop-icons="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
|
96 | alias show-desktop-icons="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
|
97 |
|
98 | for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
|
99 | alias "${method}"="lwp-request -m '${method}'"
|
100 | done
|
101 |
|
102 | hash git &>/dev/null;
|
103 | if [ $? -eq 0 ]; then
|
104 | function diff() {
|
105 | git diff --no-index --color-words "$@";
|
106 | }
|
107 | fi;
|
108 |
|
109 |
|
110 |
|
111 |
|
112 | function hierarchy() {
|
113 | tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX;
|
114 | }
|
115 |
|
116 |
|
117 | function sizeof() {
|
118 | if du -b /dev/null > /dev/null 2>&1; then
|
119 | local arg=-sbh;
|
120 | else
|
121 | local arg=-sh;
|
122 | fi
|
123 | if [[ -n "$@" ]]; then
|
124 | du $arg -- "$@";
|
125 | else
|
126 | du $arg .[^.]* ./*;
|
127 | fi;
|
128 | }
|
129 |
|
130 | function targz() {
|
131 | local tmpFile="${@%/}.tar";
|
132 | tar -cvf "${tmpFile}" --exclude=".DS_Store" "${@}" || return 1;
|
133 |
|
134 | size=$(
|
135 | stat -f"%z" "${tmpFile}" 2> /dev/null;
|
136 | stat -c"%s" "${tmpFile}" 2> /dev/null;
|
137 | );
|
138 |
|
139 | local cmd="";
|
140 | if (( size < 52428800 )) && hash zopfli 2> /dev/null; then
|
141 |
|
142 | cmd="zopfli";
|
143 | else
|
144 | if hash pigz 2> /dev/null; then
|
145 | cmd="pigz";
|
146 | else
|
147 | cmd="gzip";
|
148 | fi;
|
149 | fi;
|
150 |
|
151 | echo "Compressing .tar ($((size / 1000)) kB) using \`${cmd}\`…";
|
152 | "${cmd}" -v "${tmpFile}" || return 1;
|
153 | [ -f "${tmpFile}" ] && rm "${tmpFile}";
|
154 |
|
155 | zippedSize=$(
|
156 | stat -f"%z" "${tmpFile}.gz" 2> /dev/null;
|
157 | stat -c"%s" "${tmpFile}.gz" 2> /dev/null;
|
158 | );
|
159 |
|
160 | echo "${tmpFile}.gz ($((zippedSize / 1000)) kB) created successfully.";
|
161 | }
|
162 |
|
163 |
|
164 | alias chown='chown --preserve-root'
|
165 |
|
166 | alias chgrp='chgrp --preserve-root'
|
167 |
|
168 | alias rm="/bin/rm -i"
|
169 |
|
170 |
|
171 |
|
172 | extract () {
|
173 | if [ -f $1 ] ; then
|
174 | case $1 in
|
175 | *.tar.bz2) tar xjf $1 ;;
|
176 | *.tar.gz) tar xzf $1 ;;
|
177 | *.bz2) bunzip2 $1 ;;
|
178 | *.rar) unrar e $1 ;;
|
179 | *.gz) gunzip $1 ;;
|
180 | *.tar) tar xf $1 ;;
|
181 | *.tbz2) tar xjf $1 ;;
|
182 | *.tgz) tar xzf $1 ;;
|
183 | *.zip) unzip $1 ;;
|
184 | *.Z) uncompress $1 ;;
|
185 | *.7z) 7z x $1 ;;
|
186 | *) echo "'$1' cannot be extracted via extract()" ;;
|
187 | esac
|
188 | else
|
189 | echo "'$1' is not a valid file"
|
190 | fi
|
191 | }
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 | pid () { lsof -t -c "$@" ; }
|
200 |
|
201 |
|
202 |
|
203 | about() {
|
204 | local U
|
205 | U= `whoami`
|
206 | echo -e "\nYou are logged on ${RED}$HOST as $IM"
|
207 | echo -e "\nAdditionnal information:$NC " ; uname -a
|
208 | echo -e "\n${RED}Users logged on:$NC " ; w -h
|
209 | echo -e "\n${RED}Current date :$NC " ; date
|
210 | echo -e "\n${RED}Machine stats :$NC " ; uptime
|
211 | echo -e "\n${RED}Current network location :$NC " ; scselect
|
212 | echo -e "\n${RED}Local IP Address :$NC " ; ipin
|
213 | echo -e "\n${RED}Public facing IP Address :$NC " ; ipout
|
214 |
|
215 | echo
|
216 | }
|
217 |
|
218 | #!/usr/bin/env bash
|
219 |
|
220 |
|
221 |
|
222 |
|
223 | googl() {
|
224 | [[ ! $1 ]] && { echo -e "Usage: goo.gl [URL]\n\nShorten a URL using the Google URL Shortener service (http://goo.gl)."; return; }
|
225 | curl -qsSL -m10 --connect-timeout 10 \
|
226 | 'https://www.googleapis.com/urlshortener/v1/url' \
|
227 | -H 'Content-Type: application/json' \
|
228 | -d '{"longUrl":"'${1//\"/\\\"}'"}' |
|
229 | perl -ne 'if(m/^\s*"id":\s*"(.*)",?$/i) { print $1 }'
|
230 | }
|
231 |
|
232 |
|
233 | alias short="googl"
|
234 |
|
235 |
|
236 | export BACK_HISTORY=""
|
237 | export FORWARD_HISTORY=""
|
238 |
|
239 | function cd {
|
240 | BACK_HISTORY=$PWD:$BACK_HISTORY
|
241 | FORWARD_HISTORY=""
|
242 | builtin cd "$@"
|
243 | }
|
244 |
|
245 | function back {
|
246 | DIR=${BACK_HISTORY%%:*}
|
247 | if [[ -d "$DIR" ]]
|
248 | then
|
249 | BACK_HISTORY=${BACK_HISTORY#*:}
|
250 | FORWARD_HISTORY=$PWD:$FORWARD_HISTORY
|
251 | builtin cd "$DIR"
|
252 | fi
|
253 | }
|
254 |
|
255 | function forward {
|
256 | DIR=${FORWARD_HISTORY%%:*}
|
257 | if [[ -d "$DIR" ]]
|
258 | then
|
259 | FORWARD_HISTORY=${FORWARD_HISTORY#*:}
|
260 | BACK_HISTORY=$PWD:$BACK_HISTORY
|
261 | builtin cd "$DIR"
|
262 | fi
|
263 | }
|