-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbashrc
171 lines (143 loc) · 4.94 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
##################################
# #
# BASH Functions #
# #
##################################
function GIT_BRANCH_PROMPT()
{
GIT_BRANCH=$(git branch 2>/dev/null| sed -n "/^\*/s/^\* //p")
if [[ "$GIT_BRANCH" != "" ]]; then
echo " (git: $GIT_BRANCH)"
else
echo ""
fi
}
function DockerImagesCleanAll()
{
docker images | awk 'NR>1 {print $3}' | xargs -L 1 -t docker rmi -f
}
Machine=$(uname)
## Set the bash prompt
# Pattern for setting color -> \[\033[TEXTFORMAT;COLORm\]YOURTEXT
# To reset back to default color and format: \[\033[00m\]
#
# TEXTFORMATS
# 0 - no format
# 1 - bold
# 2 - darken
# 3 - italic
# 4 - underscore
# 5 - blink
# 9 - strikethrough
#
# FG COLORS
# 30 - black
# 31 - red
# 32 - green
# 33 - yellow
# 34 - blue
# 35 - purple
# 36 - cyan
# 37 - grey / white
# Breakup of below PS1 string
# PS1=
# \[\033[1;37m\][ - <bold><white>[
# \[\033[0;32m\]\w - <green>path-to-current-dir
# \[\033[0;34m\]`GIT_BRANCH_PROMPT` - <space><blue>(current-git-branch)<space>
# \[\033[0;35m\](\D{%e-%b-%Y %T}) - <purple>(29-Mar-2023 15:11:23)
# \[\033[1;37m\]] - <bold><white>]
# \[\033[00m\] - RESET to default style
# \n - NEWLINE
# \[\033[01;37m\]> - <bold><white>RIGHT_ARROW1
# \[\033[00m\] ' - RESET to default style<space>
PS1='\[\033[1;37m\][\[\033[0;32m\]\w \[\033[0;36m\]`GIT_BRANCH_PROMPT` \[\033[0;35m\](\D{%d-%b-%Y %T})\[\033[1;37m\]]\[\033[00m\]\n\[\033[01;37m\]>\[\033[00m\] '
#PS1='\e[1;37m[\e[0;32m\w\e \e[0;34m`GIT_BRANCH_PROMPT` \e[0;35m(\D{%e-%b-%Y %T})\e[1;37m]\e[00m\n\e[01;37m>\e[00m '
export EDITOR=vim
export TERM=xterm
##################################
# #
# BASH Command Aliases #
# #
##################################
if [ "$Machine" = "Linux" ]; then
alias ls='ls --color=auto'
alias ll='ls -lh'
elif [ "$Machine" = "Darwin" ]; then
alias ll='ls -l'
fi
alias ll='ls -ltrhF'
alias pd='pushd'
alias p='popd'
alias scrls='screen -ls'
alias scrctl='screen -m -A -d -R'
alias scrjoin='screen -A -x'
# tmux options
# -A if session with same name exists attach to it, if not create it
# -D if session is already attached to another terminal detach it there
# -s create session with name or attach to named session
alias tmx='tmux new -A -D -s'
alias docker-images-cleanall='DockerImagesCleanAll'
alias listen-ports='sudo lsof -i -P -n -i | grep LISTEN'
# path to $HOME/bin if it exists
if [[ "$PATH" != *"$HOME/bin"* ]]; then
if [ -d $HOME/bin ]; then
export PATH=$PATH:$HOME/bin;
fi
fi
# add path to brew if it is installed
if [ -d /opt/homebrew/bin ]; then
export PATH=/opt/homebrew/bin:$PATH
fi
# add path to brew if it is installed
if [ -d /opt/homebrew/sbin ]; then
export PATH=/opt/homebrew/sbin:$PATH
fi
## Some modifications to persist bash history across tmux sessions
# Make sure bash history is persisted
# across sessions and not overwritten
shopt -s histappend
# Save history after each command
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
# Increase the size of the history file
export HISTFILESIZE=10000
export HISTSIZE=5000
# Avoid duplicate entries
export HISTCONTROL=ignoredups:erasedups
## Node - Node enVironment Manager
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
## RVB - Ruby enVironment Manager
[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion # Enable RVM tab suggestion
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
## Enable brew autocomplete
if type brew &>/dev/null
then
HOMEBREW_PREFIX="$(brew --prefix)"
if [[ -r "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh" ]]
then
source "${HOMEBREW_PREFIX}/etc/profile.d/bash_completion.sh"
else
for COMPLETION in "${HOMEBREW_PREFIX}/etc/bash_completion.d/"*
do
[[ -r "${COMPLETION}" ]] && source "${COMPLETION}"
done
fi
fi
## Pyenv configs
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
# Add pipx bin path to PATH env var
# Created by `pipx` on 2023-04-03 17:40:48
export PATH="$PATH:/Users/santhosh/.local/bin"
# Enable pipx completions
eval "$(register-python-argcomplete pipx)"
# Install pip packages only in virtual envs
export PIP_REQUIRE_VIRTUALENV=true
# Configure shell for rust toolchain
[[ -r $HOME/.cargo/env ]] && . "$HOME/.cargo/env"
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"