-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_profile
executable file
·243 lines (192 loc) · 7.15 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
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# _ _ __ _ _
# | |__ __ _ ___| |__ _ __ _ __ ___ / _(_) | ___
# | '_ \ / _` / __| '_ \ | '_ \| '__/ _ \| |_| | |/ _ \
# | |_) | (_| \__ \ | | | | |_) | | | (_) | _| | | __/
# |_.__/ \__,_|___/_| |_| | .__/|_| \___/|_| |_|_|\___|
# |_|
# When Bash starts, it executes the commands in this script
# http://en.wikipedia.org/wiki/Bash_(Unix_shell)
# Written by Philip Lamplugh, Instructor General Assembly (2013)
# Updated by PJ Hughes, Instructor General Assembly (2013)
# =====================
# Resources
# =====================
# http://cli.learncodethehardway.org/bash_cheat_sheet.pdf
# http://ss64.com/bash/syntax-prompt.html
# https://dougbarton.us/Bash/Bash-prompts.html
# http://sage.ucsc.edu/xtal/iterm_tab_customization.html
# ====================
# TOC
# ====================
# --------------------
# System Settings
# --------------------
# Path List
# Settings
# History
# Aliases
# Other System Settings
# --------------------
# Application Settings
# --------------------
# Application Aliases
# rbenv
# --------------------
# Other Settings
# --------------------
# Shortcuts
# Source Files
# Environmental Variables and API Keys
# Colophon
# -----------------------------------------------------------------------------
# Path
# A list of all directories in which to look for commands, scripts and programs
# -----------------------------------------------------------------------------
PATH="/usr/local/share/npm/bin:$PATH" # NPM
PATH="/usr/local/share/dotnet:$PATH" # dotnet
PATH="/usr/local/bin:/usr/local/sbin:$PATH" # Homebrew
# PATH="/usr/local/heroku/bin:$PATH" # Heroku Toolbelt
PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" # Coreutils
MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH" # Manual pages
export GOPATH="$HOME/src/go" # Go
export GOROOT="/usr/local/go"
PATH="$PATH:$GOROOT/bin:$GOPATH/bin" # Go Binaries
whoami=`who | awk '{print $1}' | head -1`
# =================
# Settings
# =================
# Prefer US English
export LC_ALL="en_US.UTF-8"
# use UTF-8
export LANG="en_US"
# # Adds colors to LS!!!!
# export CLICOLOR=1
# # http://geoff.greer.fm/lscolors/
# # Describes what color to use for which attribute (files, folders etc.)
# export LSCOLORS=exfxcxdxbxegedabagacad # PJ: turned off
# export LS_COLORS="di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:"
# =================
# History
# =================
# http://jorge.fbarr.net/2011/03/24/making-your-bash-history-more-efficient/
# Larger bash history (allow 32³ entries; default is 500)
export HISTSIZE=32768
export HISTFILESIZE=$HISTSIZE
# don't put duplicate lines in the history.
export HISTCONTROL=ignoredups
# ignore same sucessive entries.
export HISTCONTROL=ignoreboth
# Make some commands not show up in history
export HISTIGNORE="h"
# ====================
# Aliases
# ====================
# LS lists information about files.
# show slashes for directories.
alias ls='ls -F'
# long list format including hidden files and include unit size
alias ll='ls -la'
# go back one directory
alias b='cd ..'
# History lists your previously entered commands
alias h='history'
# mkdir + cd into it
mcd () {
mkdir -p -- "$1" && cd -P -- "$1"
}
# If we make a change to our bash profile we need to reload it
alias reload="clear; source ~/.bash_profile && nvm use"
# confirm before executing and be verbose
alias cp='cp -iv'
alias mv='mv -iv'
# alias rm='rm -iv'
alias mkdir='mkdir -pv'
# =================
# Additional Aliases
# =================
# Hide/show all desktop icons (useful when presenting)
alias hide_desktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias show_desktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
# Hide/show hidden files in Finder
alias hide_files="defaults write com.apple.finder AppleShowAllFiles FALSE && killall Finder"
alias show_files="defaults write com.apple.finder AppleShowAllFiles TRUE && killall Finder"
# List any open internet sockets on several popular ports.
# Useful if a rogue server is running
# http://www.akadia.com/services/lsof_intro.html
# http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
alias rogue='lsof -i TCP:3000 -i TCP:4567 -i TCP:8000 -i TCP:8888 -i TCP:6379'
type hub >/dev/null 2>&1 && alias git=hub
# Opens github
if [ -f ~/.gh.sh ]; then
alias gh='~/.gh.sh'
fi
# ================
# Application Aliases
# ================
# Sublime should be symlinked. Otherwise use one of these
# alias subl='open -a "Sublime Text"'
# alias subl='open -a "Sublime Text 2"'
alias chrome='open -a "Google Chrome"'
# =================
# rbenv
# =================
# start rbenv (our Ruby environment and version manager) on open
# if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
# =================
# Functions
# =================
#######################################
# Start an HTTP server from a directory
# Arguments:
# Port (optional)
#######################################
server() {
local port="${1:-8000}"
open "http://localhost:${port}/"
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
# Simple Pythong Server:
# python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
# Simple Ruby Webrick Server:
ruby -e "require 'webrick';server = WEBrick::HTTPServer.new(:Port=>${port},:DocumentRoot=>Dir::pwd );trap('INT'){ server.shutdown };server.start"
}
# =================
# Tab Improvements
# =================
## Tab improvements
# ## Might not need?
# bind 'set completion-ignore-case on'
# # make completions appear immediately after pressing TAB once
bind 'set show-all-if-ambiguous on'
bind 'TAB: menu-complete'
# =================
# Sourced Scripts
# =================
# Builds the prompt with git branch notifications.
if [ -f ~/.bash_prompt.sh ]; then
source ~/.bash_prompt.sh
fi
# bash/zsh completion support for core Git.
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi
#load user specific aliases
if [ -f ~/.bash_aliases.local ]; then
. ~/.bash_aliases.local
fi
if [ -f /usr/local/bin/fuck ]; then
eval $(thefuck --alias)
fi
# ====================================
# Environmental Variables and API Keys
# ====================================
if [ -f ~/.bash_secrets.local ]; then
. ~/.bash_secrets.local
fi
# Below here is an area for other commands added by outside programs or
# commands. Attempt to reserve this area for their use!
##########################################################################
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH="$PATH:$HOME/.rvm/bin"