/
.bash_profile
175 lines (153 loc) · 12.6 KB
/
.bash_profile
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
no# -------------------------------------------------------------
# NETWORKING
# -------------------------------------------------------------
alias netCons='lsof -i' # netCons: Show all open TCP/IP sockets
alias flushDNS='dscacheutil -flushcache' # flushDNS: Flush out the DNS Cache
alias lsock='sudo /usr/sbin/lsof -i -P' # lsock: Display open sockets
alias net='ping google.com' # net: Cheat
alias lsockU='sudo /usr/sbin/lsof -nP | grep UDP' # lsockU: Display only open UDP sockets
alias lsockT='sudo /usr/sbin/lsof -nP | grep TCP' # lsockT: Display only open TCP sockets
alias en0="ifconfig en0 | grep ether" # ipInfo0: Get info on connections for en0
alias en1="ifconfig en1 | grep ether" # ipInfo1: Get info on connections for en1
alias openPorts='sudo lsof -i | grep LISTEN' # openPorts: All listening connections
alias showBlocked='sudo ipfw list' # showBlocked: All ipfw rules inc/ blocked IPs
alias getip="curl ipecho.net/plain ; echo" # getip: Preferred ip echo implementation
alias inet="ifconfig | grep inet" # inet: Preferred ifconfig implementation
alias prof="atom ~/.bash_profile" # prof: Preferred bash_profile edit implementation
alias re='source ~/.bash_profile' # re: Preferred bash_profile reload implementation
alias mem='sudo purge' # re: Flush memory
alias rout='traceroute ' # rout: Traceroute
alias nets='netstat -ap tcp ' # nets: Active Internet connections, including servers
alias nettcp='netstat -atp tcp | grep -i "listen" ' # nettcp: Active Internet connections, including servers
alias proxyoff='sudo networksetup -setsocksfirewallproxystate Wi-Fi off ' # proxyoff: Set Socks5 proxy off
alias proxyon='sudo networksetup -setsocksfirewallproxystate Wi-Fi on ' # proxyon: Set Socks5 proxy on
alias pro='/Applications/pro.sh ' # pro: Get network stats
alias prox='/Applications/prox.sh ' # prox: Start secure session
alias flush='rm -rf /.DocumentRevisions-V100/; rm -rf /private/var/vm ' # flush: Remove /.DocumentRevisions
alias wnet='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -s' # wnet: View wireless networks
# -------------------------------------------------------------
# TERMINAL / COMMON
# -------------------------------------------------------------
alias .='cd ~' # .: Go to Home directory from anywhere
alias w='pwd' # w: List working directory
alias c="cd" # c: Show current directory
alias f='open -a Finder ./' # f: Opens current directory in MacOS Finder
alias cp='cp -iv' # cp: Preferred implementation
alias mv='mv -iv' # mv: Preferred implementation
alias edit='atom' # edit: Opens any file in atom editor
alias ls='ls -lah $LS_COLOR' # ls: Preferred implementation
alias path='echo -e ${PATH//:/\\n}' # path: Echo all executable Paths
alias cic='set completion-ignore-case On' # cic: Make tab-completion case-insensitive
alias des='cd ~/Desktop' # des: Go to desktop from anywhere
alias dow='cd ~/Downloads' # dow: Go to downloads from anywhere
alias doc='cd ~/Documents' # doc: Go to Documents from anywhere
# -------------------------------------------------------------------------------------------------------------------------------------------
mcd () { mkdir -p "$1" && cd "$1"; } # mcd: Makes new Dir and jumps inside
trash () { command mv "$@" ~/.Trash ; } # trash: Moves a file to the MacOS trash
ql () { qlmanage -p "$*" >& /dev/null; } # ql: Opens any file in MacOS Quicklook Preview
# -------------------------------------------------------------
# SET DEFAULT EDITOR
# -------------------------------------------------------------
export EDITOR=/usr/bin/atom # Set default editor
# -------------------------------------------------------------
# FILE AND FOLDER MANAGEMENT
# -------------------------------------------------------------
zipf () { zip -r "$1".zip "$1" ; } # zipf: To create a ZIP archive of a folder
# -------------------------------------------------------------
# EXTRACT / MOST KNOWN ARCHIVE FORMATS
# -------------------------------------------------------------
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
# -------------------------------------------------------------
# UP MULTIPLE DIRECTORIES
# -------------------------------------------------------------
up() { cd $(eval printf '../'%.0s {1..$1}) && pwd; }
# -------------------------------------------------------------
# WEB / COMMON
# -------------------------------------------------------------
alias header='curl -I' # Get web server headers #
alias headerc='curl -I --compress' # Find out if remote server supports gzip / mod_deflate or not #
alias apacheEdit='sudo edit /etc/httpd/httpd.conf' # apacheEdit: Edit httpd.conf
alias apacheRestart='sudo apachectl graceful' # apacheRestart: Restart Apache
alias editHosts='sudo edit /etc/hosts' # editHosts: Edit /etc/hosts file
alias herr='tail /var/log/httpd/error_log' # herr: Tails HTTP error logs
alias apacheLogs="less +F /var/log/apache2/error_log" # Apachelogs: Shows apache error logs
alias pyServer="python -m SimpleHTTPServer" # Python server from current directory tree at http://$HOSTNAME:8000/
alias phpServer="php -S 127.0.0.1:8080" # PHP server from current directory tree at http://$HOSTNAME:8080/
# -------------------------------------------------------------
# SYSTEMS OPERATIONS & INFORMATION
# -------------------------------------------------------------
alias mountReadWrite='/sbin/mount -uw /' # mountReadWrite: For use when booted into single-user
alias cleanupDS="find . -type f -name '*.DS_Store' -ls -delete" # cleanupDS: Recursively delete .DS_Store files
alias ShowHidden='defaults write com.apple.finder ShowAllFiles TRUE' # finderShowHidden: Show hidden files in Finder
alias HideHidden='defaults write com.apple.finder ShowAllFiles FALSE' # finderHideHidden: Hide hidden files in Finder
# -------------------------------------------------------------
# Setting PATH for Python 3.5 / Orginal in .bash_profile.pysave
# -------------------------------------------------------------
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH
# -------------------------------------------------------------
# Git Common Aliases
# -------------------------------------------------------------
alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gd='git diff'
alias go='git checkout '
alias gk='gitk --all&'
alias gx='gitx --all'
alias gp='git push origin master' # gp: This one is a joke
alias got='git '
alias get='git '
# -------------------------------------------------------------
# Wget
# -------------------------------------------------------------
alias wall='wget -e robots=off -x --mirror --recursive --page-requisites'
# -------------------------------------------------------------
# Misc
# -------------------------------------------------------------
alias stat='du -sh *' # stat: Displays disk usage information for directory's
alias home='du -sh' # home: Displays disk usage information for home directory
alias disk='df -h' # disk: Displays disk usage information / all disks
# MacPorts Installer addition on 2016-05-15_at_01:04:43: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.
# -------------------------------------------------------------
# SYSTEM
# -------------------------------------------------------------
alias sys='sysctl -n machdep.cpu.brand_string' # Get CPU information
alias headerc='curl -I --compress' # Find out if remote server supports gzip / mod_deflate or not #
alias apacheEdit='sudo edit /etc/httpd/httpd.conf' # apacheEdit: Edit httpd.conf
alias apacheRestart='sudo apachectl graceful' # apacheRestart: Restart Apache
alias editHosts='sudo edit /etc/hosts' # editHosts: Edit /etc/hosts file
alias herr='tail /var/log/httpd/error_log' # herr: Tails HTTP error logs
alias apacheLogs="less +F /var/log/apache2/error_log" # Apachelogs: Shows apache error logs
alias pyServer="python -m SimpleHTTPServer" # Python server from current directory tree at http://$HOSTNAME:8000/
alias phpServer="php -S 127.0.0.1:8080" # PHP server from current directory tree at http://$HOSTNAME:8080/
alias secureerase="diskutil secureErase freespace 0 /Volumes/Macintosh\ HD" # Erase Free Hard Drive Space Securely
# -------------------------------------------------------------
# Net
# -------------------------------------------------------------
alias da='youtube-dl --extract-audio --audio-format mp3 ' # Extract audio from YouTube | Requires [youtube-dl lib]
# MacPorts Installer addition on 2016-07-30_at_13:52:31: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.