-
Notifications
You must be signed in to change notification settings - Fork 1
/
bashrc
executable file
·246 lines (185 loc) · 7.28 KB
/
bashrc
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
244
245
246
#!/usr/bin/env bash
# .bashrc
# Author: AJ Acevedo
# Author URI: http://AJAlabs.com
# License: MIT
#-------------------------------------------------------------
# Ignore bashrc for non-interactive shells
#-------------------------------------------------------------
if [[ $- != *i* ]]; then
return;
fi
#-------------------------------------------------------------
# Source global definitions (if any exist)
#-------------------------------------------------------------
# For macOS
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# For Debian Linux
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
#-------------------------------------------------------------
# Source private bash definitions (if any exist)
#-------------------------------------------------------------
if [ -f ~/.bash_private ]; then
source ~/.bash_private
fi
#-------------------------------------------------------------
# aliases - Global
#-------------------------------------------------------------
alias ..1='cd ../'
alias ..2='cd ../../'
alias ..3='cd ../../../'
alias ..4='cd ../../../../'
alias ..5='cd ../../../../../'
alias gd='git diff'
alias gm='git merge --no-ff'
alias gs='git status'
alias mb='mv'
alias .s='source ~/.bashrc'
alias tocuh='touch'
alias showip='ifconfig | grep "inet" | grep -v 127.0.0.1'
alias fixRSA='ssh-keygen -f ~/.ssh/known_hosts -R'
alias sshit="ssh -oHostKeyAlgorithms=ssh-rsa -o KexAlgorithms=diffie-hellman-group1-sha1 -o Ciphers=aes256-cbc,3des-cbc"
#-------------------------------------------------------------
# History
#-------------------------------------------------------------
# Set History Size to 50,000 line! Yeah buddy!
export HISTSIZE=50000
# Append to bash_history and do not overwrite
shopt -s histappend
# Ignore duplicates, erase duplicates and ignore lines that start with a space
export HISTCONTROL=ignoreboth:erasedups
#-------------------------------------------------------------
# PS1 PROMPT 'user@hostname cwd (git_branch • )$ '
#-------------------------------------------------------------
if [ -f ~/.dotfiles/config/git-prompt.sh ]; then
# Add Git repo/branch and status to the PS1 PROMPT
source ~/.dotfiles/config/git-prompt.sh
# echo -n -e "\033]0;`basename $PWD`\007" Adds the cwd to the shell window and tab
PROMPT_COMMAND='__git_ps1 "\u@\h \W" "\\\$ ";echo -n -e "\033]0;`basename $PWD`\007"'
echo -n -e "\033]0;`basename $PWD`\007"
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
fi
#-------------------------------------------------------------
# MISC
#-------------------------------------------------------------
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
#-------------------------------------------------------------
# PATHS
#-------------------------------------------------------------
# Prepend Homebrew's PATH before $PATH
export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/local/sbin:$PATH"
# Add ~/bin
export PATH=$PATH:$HOME/bin
# Add RVM to PATH for scripting
PATH=$PATH:$HOME/.rvm/bin
# Clean up duplicates in $PATH and remove trailing :
PATH=$(echo -n $PATH | awk -v RS=: -v ORS=: '!($0 in a) {a[$0]; print}' | sed "s/\(.*\).\{1\}/\1/")
#-------------------------------------------------------------
# TAB Auto-Completion
#-------------------------------------------------------------
# Grunt JS - requires grunt to be installed globally with
# npm install -g grunt
[[ -r "$HOME/.npm/grunt" ]] && eval "$(grunt --completion=bash)"
# RVM - Requires RVM to be installed
[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion
# Git
if [ -f ~/.dotfiles/config/git-completion.sh ]; then
source ~/.dotfiles/config/git-completion.sh
fi
#-------------------------------------------------------------
# Environments
#-------------------------------------------------------------
export NODE_ENV=development
#-------------------------------------------------------------
# RVM - Ruby Version Manager
#-------------------------------------------------------------
# Load RVM into a shell session *as a function* if it exists
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
#-------------------------------------------------------------
# Python
#-------------------------------------------------------------
# Prevent those pesky .pyc and __pycache__ files/folder from being created.
export PYTHONDONTWRITEBYTECODE=1
# Also setup some python aliases
#TODO: Fix conditional to not use which
#if which python3 >/dev/null; then
# export PYTHONDONTWRITEBYTECODE=1
# alias python='python3'
# alias pip='pip3'
#else
# echo "Python is not installed"
#fi
# Required for pyenv - https://github.com/pyenv/pyenv
eval "$(pyenv init -)"
export PYENV_VERSION=3.10.4
##############################################################
# BEGIN - macOS Specific configurations
##############################################################
if [ `uname -s` == "Darwin" ]; then
# Silence the bash deprecation warning
export BASH_SILENCE_DEPRECATION_WARNING=1
#-------------------------------------------------------------
# macOS specific aliases
#-------------------------------------------------------------
#alias ls='ls -f1 -lh' THIS IS BROKEN in macOS 10.13
alias ls='ls -alh'
alias myip='ipconfig getifaddr en0'
#-------------------------------------------------------------
# Set default Editor to VS Code
#-------------------------------------------------------------
export EDITOR="code --wait"
export GIT_EDITOR="$EDITOR"
export VISUAL="$EDITOR"
#-------------------------------------------------------------
# CLI COLOR
#-------------------------------------------------------------
export CLICOLOR=1
export LSCOLORS=gxcxfxdxbxegedabagDxad
fi
#-------------------------------------------------------------
# Set UTF 8 Locales
#-------------------------------------------------------------
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
##############################################################
# END - macOS Specific configurations
##############################################################
##############################################################
# BEGIN - Linux Specific configurations
##############################################################
if [ `uname -s` == "Linux" ]; then
#-------------------------------------------------------------
# Linux specific aliases
#-------------------------------------------------------------
alias ls='ls -alh --color'
#-------------------------------------------------------------
# Set default Editor to vi
#-------------------------------------------------------------
export EDITOR=vim
export GIT_EDITOR=vim
export VISUAL=vim
#-------------------------------------------------------------
# CLI COLOR
#-------------------------------------------------------------
export CLICOLOR=1
export LS_COLORS='di=36:ln=32:so=35:pi=33:ex=31:or=31;5'
#-------------------------------------------------------------
# NodeJS JavaScript runtime
#-------------------------------------------------------------
#TODO: Fix conditional to not use which
if which node >/dev/null; then
export EXECJS_RUNTIME=node
else
echo "Node is not installed"
fi
fi
##############################################################
# END - Linux Specific configurations
##############################################################