-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.bashrc
356 lines (300 loc) · 13.4 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# Init Path {{{
[ -d /usr/local/sbin ] && export PATH="/usr/local/sbin:${PATH}"
[ -d /usr/local/bin ] && export PATH="/usr/local/bin:${PATH}"
[ -d /usr/local/opt/coreutils/libexec/gnubin ] && export PATH="/usr/local/opt/coreutils/libexec/gnubin:${PATH}"
[ -d /usr/local/opt/findutils/libexec/gnubin ] && export PATH="/usr/local/opt/findutils/libexec/gnubin:${PATH}"
[ -d /usr/local/opt/gnu-sed/libexec/gnubin ] && export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:${PATH}"
[ -d /usr/local/opt/make/libexec/gnubin ] && export PATH="/usr/local/opt/make/libexec/gnubin:${PATH}"
[ -d /opt/homebrew/opt/coreutils/libexec/gnubin ] && export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:${PATH}"
[ -d /opt/homebrew/opt/findutils/libexec/gnubin ] && export PATH="/opt/homebrew/opt/findutils/libexec/gnubin:${PATH}"
[ -d /opt/homebrew/opt/gnu-sed/libexec/gnubin ] && export PATH="/opt/homebrew/opt/gnu-sed/libexec/gnubin:${PATH}"
[ -d /opt/homebrew/opt/make/libexec/gnubin ] && export PATH="/opt/homebrew/opt/make/libexec/gnubin:${PATH}"
[ -d /opt/ruby/bin ] && export PATH="/usr/local/opt/ruby/bin:${PATH}"
[ -d /opt/homebrew/opt/ruby/bin ] && export PATH="/opt/homebrew/opt/ruby/bin:${PATH}"
[ -r "${HOME}/.cargo/env" ] && . "${HOME}/.cargo/env"
[ -d "$HOME/bin" ] && export PATH="$HOME/bin:${PATH}"
[ -d "$HOME/.local/bin" ] && export PATH="${HOME}/.local/bin:${PATH}"
[ -d "${HOME}/.local/share/nvim/mason/bin" ] && export PATH="${HOME}/.local/share/nvim/mason/bin:${PATH}"
[ -f "/Applications/WezTerm.app/Contents/MacOS/wezterm" ] && export PATH="/Applications/WezTerm.app/Contents/MacOS:${PATH}"
if [ -f /opt/homebrew/bin/brew ]; then
# this is slow, that is why we export directly
# eval "$(/opt/homebrew/bin/brew shellenv)"
export HOMEBREW_PREFIX="/opt/homebrew";
export HOMEBREW_CELLAR="/opt/homebrew/Cellar";
export HOMEBREW_REPOSITORY="/opt/homebrew";
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin${PATH+:$PATH}";
export MANPATH="/opt/homebrew/share/man${MANPATH+:$MANPATH}:";
export INFOPATH="/opt/homebrew/share/info:${INFOPATH:-}";
elif [ -f /usr/local/bin/brew ]; then
# this is slow, that is why we export directly
# eval "$(/usr/local/bin/brew shellenv)"
export HOMEBREW_PREFIX="/opt/homebrew";
export HOMEBREW_CELLAR="/opt/homebrew/Cellar";
export HOMEBREW_REPOSITORY="/opt/homebrew";
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin${PATH+:$PATH}";
export MANPATH="/opt/homebrew/share/man${MANPATH+:$MANPATH}:";
export INFOPATH="/opt/homebrew/share/info:${INFOPATH:-}";
# Instead of add ~/.dotfiles-site/linuxbrew.sh to /etc/bash.bashrc
# elif [ -f /home/linuxbrew/.linuxbrew/bin/brew ]; then
# export HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew";
# export HOMEBREW_CELLAR="/home/linuxbrew/.linuxbrew/Cellar";
# export HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew";
# export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin${PATH+:$PATH}";
# export MANPATH="/home/linuxbrew/.linuxbrew/share/man${MANPATH+:$MANPATH}:";
# export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:${INFOPATH:-}";
fi
# }}}
# If not running interactively, don't do anything
if [[ $- != *i* ]] ; then
if type -P mise >/dev/null ; then
eval "$(mise activate bash --shims)"
elif [ -f /usr/local/opt/asdf/libexec/asdf.sh ]; then
. /usr/local/opt/asdf/libexec/asdf.sh
elif [ -f /opt/homebrew/opt/asdf/libexec/asdf.sh ]; then
. /opt/homebrew/opt/asdf/libexec/asdf.sh
elif [ -f /opt/asdf-vm/asdf.sh ]; then
. /opt/asdf-vm/asdf.sh
elif [ -f ${HOME}/.asdf/asdf.sh ]; then
. ${HOME}/.asdf/asdf.sh
fi
return
fi
# Good Shell {{{
# If set, bash checks the window size after each external (non-builtin) command and, if necessary, updates the values of LINES
# and COLUMNS. This option is enabled by default.
shopt -s checkwinsize
# shut up macOS cwd echo (in Terminal app, iTerm is okay):
# > It updates the prompt to echo the Current Working Directory (CWD) and is defined in /etc/bashrc
update_terminal_cwdprintf() {
echo -n
}
export BASH_SILENCE_DEPRECATION_WARNING=1
# append new history items to .bash_history
shopt -s histappend
# don't put duplicate lines or lines starting with space in the history
HISTCONTROL="ignoredups:erasedups"
# increase history file size
HISTFILESIZE=1000000
# increase history size
HISTSIZE=${HISTFILESIZE}
# append new entries from memory to .bash_history, and vice-versa
PROMPT_COMMAND="history -a; history -n;" ## ${PROMPT_COMMAND}"
if type -P direnv >/dev/null ; then
eval "$(direnv hook bash)"
fi
# Change the window title of X terminals
# if something adds to PROMPT_COMMAND later, there would be no space between that and printf
# case ${TERM} in
# xterm*|rxvt*|Eterm|aterm|kterm|gnome*|terminator*)
# PROMPT_COMMAND=${PROMPT_COMMAND}'printf "\033]0;%s@%s:%s\007" "$USER" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
# ;;
# screen)
# PROMPT_COMMAND=${PROMPT_COMMAND}'printf "\033_%s@%s:%s\033\\" "$USER" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
# ;;
# esac
# Use my colors
if type -P dircolors >/dev/null ; then
if [[ -f ~/.dir_colors ]] ; then
eval $(dircolors -b ~/.dir_colors)
elif [[ -f /etc/DIR_COLORS ]] ; then
eval $(dircolors -b /etc/DIR_COLORS)
fi
fi
# }}}
# Shell Prompt {{{
if [ -f /usr/share/git/git-prompt.sh ]; then
source /usr/share/git/git-prompt.sh
elif [ -f "~/.git-prompt.sh" ]; then
source "~/.git-prompt.sh"
elif [ -f /usr/share/git-core/contrib/completion/git-prompt.sh ]; then
# CentOS
source /usr/share/git-core/contrib/completion/git-prompt.sh
elif [ -f /usr/local/etc/bash_completion.d/git-prompt.sh ]; then
source /usr/local/etc/bash_completion.d/git-prompt.sh
elif [ -f /opt/homebrew/etc/bash_completion.d/git-prompt.sh ]; then
source /opt/homebrew/etc/bash_completion.d/git-prompt.sh
else
__git_ps1() {
return $?
}
fi
# GIT_PS1_SHOWDIRTYSTATE=1
# GIT_PS1_SHOWSTASHSTATE=1
# GIT_PS1_SHOWUNTRACKEDFILES=1
# GIT_PS1_SHOWUPSTREAM="auto"
# GIT_PS1_SHOWCOLORHINTS=1
## Prompt
if [[ ${EUID} == 0 ]] ; then
PS1='\[\033[01;30m\]\h\[\033[01;34m\] \W \[\033[01;31m\]\$\[\033[00m\] '
#PS1='\[\033[01;30m\]\u@\h\[\033[01;34m\] \W \$\[\033[00m\] '
#PS1="\[\e[01;31m\]┌─[\[\e[01;35m\u\e[01;31m\]]──[\[\e[00;37m\]${HOSTNAME%%.*}\[\e[01;32m\]]:\w$\[\e[01;31m\]\n\[\e[01;31m\]└──\[\e[01;36m\]>>\[\e[0m\]"
else
#PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \W \$\[\033[00m\] '
PS1='\[\033[01;37m\]\h\[\033[01;34m\] \W\[\033[0;36m\]$(__git_ps1 " (%s)")\[\033[0;34m\] \$\[\033[00m\] '
#PS1="\[\e[01;31m\]┌─[\[\e[01;35m\u\e[01;31m\]]──[\[\e[00;37m\]${HOSTNAME%%.*}\[\e[01;32m\]]:\w$\[\e[01;31m\]\n\[\e[01;31m\]└──\[\e[01;36m\]>>\[\e[0m\]"
fi
PS2='> '
PS3='> '
PS4='+ '
# }}}
# Setting bash_completion {{{
## Common (Ubuntu? Debian?)
if [ -r /etc/bash_completion ]; then
. /etc/bash_completion
fi
# Instead of add ~/.dotfiles-site/linuxbrew.sh to /etc/bash.bashrc
# if [ -d /home/linuxbrew/.linuxbrew/etc/bash_completion.d ]; then
# # if [ -n "$BASH_COMPLETION_USER_DIR" ]; then
# # export BASH_COMPLETION_USER_DIR="/home/linuxbrew/.linuxbrew/etc/bash_completion.d:$BASH_COMPLETION_USER_DIR"
# # else
# # export BASH_COMPLETION_USER_DIR="/home/linuxbrew/.linuxbrew/etc/bash_completion.d"
# # fi
# . /home/linuxbrew/.linuxbrew/etc/bash_completion.d/brew
# fi
## Arch (it is already being source by /etc/bash.bashrc)
# [ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
# macOS
[ -r /usr/local/etc/profile.d/bash_completion.sh ] && . /usr/local/etc/profile.d/bash_completion.sh
[ -r /opt/homebrew/etc/profile.d/bash_completion.sh ] && . /opt/homebrew/etc/profile.d/bash_completion.sh
[ -f /opt/homebrew/opt/asdf/etc/bash_completion.d/asdf.bash ] && . /opt/homebrew/opt/asdf/etc/bash_completion.d/asdf.bash
[ -f ${HOME}/.asdf/completions/asdf.bash ] && . ${HOME}/.asdf/completions/asdf.bash
if type -P mise >/dev/null ; then
eval "$(mise activate bash)"
fi
# }}}
# Aliases {{{
alias ..='cd ..'
alias ...='cd ../..'
alias ll='ls -lAF'
alias simplehttpd='python3 -m http.server';
alias simplehttpd2='python -m SimpleHTTPServer';
alias jsonformat='python -m json.tool'
if type -P nvim >/dev/null ; then
alias vim='nvim'
export EDITOR='nvim'
elif type -P hx >/dev/null ; then
export EDITOR="hx"
elif type -P vim >/dev/null ; then
export EDITOR='vim'
elif type -P vi >/dev/null ; then
alias vim='vi'
export EDITOR='vi'
fi
alias cemacs='emacs --no-window-system'
if type broot > /dev/null 2>&1; then
if [ -f ~/.config/broot/launcher/bash/br ]; then
source ~/.config/broot/launcher/bash/br
fi
fi
# [[ "$OSTYPE" == "darwin"* || "$OSTYPE" == "freebsd"* ]] && alias grep='grep --colour=auto' || grep='grep --color=auto'
if [ -n "${OSTYPE}" ]; then
if [ "${OSTYPE}" == 'linux-gnu' ]; then
alias grep='grep --color=auto'
else
alias grep='grep --colour=auto'
fi
fi
# [[ "$OSTYPE" =~ linux* ]] && alias ls='ls -G' || alias ls='ls --color=auto'
alias ls='ls --color=auto'
type colordiff > /dev/null 2>&1 && alias diff='colordiff'
type less >/dev/null 2>&1 && alias less='less -R'
type less >/dev/null 2>&1 && export PAGER='less'
alias config="git --git-dir=${HOME}/.dotfiles/ --work-tree=${HOME}"
if [ -f /usr/share/bash-completion/completions/git ]; then
source /usr/share/bash-completion/completions/git
__git_complete config __git_main
elif [ -f /usr/local/etc/bash_completion.d/git-completion.bash ]; then
source /usr/local/etc/bash_completion.d/git-completion.bash
__git_complete config __git_main
elif [ -f /opt/homebrew/etc/bash_completion.d/git-completion.bash ]; then
source /opt/homebrew/etc/bash_completion.d/git-completion.bash
__git_complete config __git_main
fi
alias gitAuthorMe='git config user.email "[email protected]"; git config user.name "Hesaam Farhang"'
alias configAuthorMe='config config user.email "[email protected]"; config config user.name "Hesaam Farhang"'
# }}}
[ -s "${HOME}/.dotfiles-site/functions" ] && source "${HOME}/.dotfiles-site/functions"
# PLATFORM=`uname -s`
# if [ x"`uname -a | grep -o Microsoft | uniq`" = x"Microsoft" ]; then
# PLATFORM="Microsoft"
# elif [ x"`uname -a | grep -o Darwin | uniq`" = x"Darwin" ]; then
# PLATFORM="Darwin"
# fi
# fzf {{{
if [ -d /home/linuxbrew/.linuxbrew/opt/fzf/shell ]; then
. /home/linuxbrew/.linuxbrew/opt/fzf/shell/key-bindings.bash
. /home/linuxbrew/.linuxbrew/opt/fzf/shell/completion.bash
elif [ -f /usr/share/fzf/key-bindings.bash ]; then
. /usr/share/fzf/key-bindings.bash
. /usr/share/fzf/completion.bash
elif [ -f /usr/local/opt/fzf/shell/key-bindings.bash ]; then
. /usr/local/opt/fzf/shell/key-bindings.bash
. /usr/local/opt/fzf/shell/completion.bash
elif [ -f /opt/homebrew/opt/fzf/shell/key-bindings.bash ]; then
. /opt/homebrew/opt/fzf/shell/key-bindings.bash
. /opt/homebrew/opt/fzf/shell/completion.bash
elif [ -f ~/.fzf.bash ]; then
. ~/.fzf.bash
fi
# }}}
# Work Dirs {{{
export iceWork="${iceWork:-${HOME}/work}"
export iceDock="${iceWork}/dockerfiles"
alias icework="cd ${iceWork}"
alias icedock="cd ${iceDock}"
# }}}
# WSL Dirs {{{
export wslHome="${wslHome:-/mnt/c/Users/hesaam}"
if [ -d "${wslHome}" ]; then
export wslDocument="${wHome}/Documents"
export wslWork="${wDocument}/work"
alias wslHome="cd ${wslHome}"
alias wslWork="cd ${wslWork}"
fi
# }}}
# Kazoo Stuff {{{
export wKazoo="${wKazoo:-${iceWork}/2600hz}"
export KAZOO_SRC="${KAZOO_SRC:-${wKazoo}/kazoo-master}"
export KZ_DOCKER_DIR="${KZ_DOCKER_DIR:-${iceDock}/kazoo}"
export KZ_COMPOSE_DIR="${KZ_DOCKER_DIR}/compose"
export KZ_DOCKER_DESKTOP="${KZ_DOCKER_DIR}/docker-desktop"
export KZ_DOCKER_DESKTOP_FILE="${KZ_DOCKER_DESKTOP}/docker-compose.yml"
alias kazoo="cd ${wKazoo}"
alias kz="cd ${wKazoo}/kazoo-master; export KAZOO_SRC=${wKazoo}/kazoo-master"
alias kz3="cd ${wKazoo}/kazoo-4.3; export KAZOO_SRC=${wKazoo}/kazoo-4.3"
alias kz50="cd ${wKazoo}/kazoo-5.0; export KAZOO_SRC=${wKazoo}/kazoo-5.0"
alias kz5="cd ${wKazoo}/kazoo-5.4; export KAZOO_SRC=${wKazoo}/kazoo-5.4"
alias docs="cd ${wKazoo}/2600hz-docs-astro"
alias appex="cd ${wKazoo}/appex-server"
alias appexx="cd ${wKazoo}/appex-marketplace"
alias market="cd ${wKazoo}/market-ecommerce-server"
alias kgit="${wKazoo}/kazoo-master/kgit"
[ -f ${wKazoo}/kazoo-master/kgit-completion.bash ] && . ${wKazoo}/kazoo-master/kgit-completion.bash
if [ -f "$KZ_DOCKER_DESKTOP_FILE" ]; then
alias kzdoc="COMPOSE_FILE=${KZ_DOCKER_DESKTOP_FILE} docker"
complete -F _docker kzdoc
fi
# }}}
# Progamming Lang Settings {{{
export ERL_AFLAGS="-kernel shell_history enabled ${ERL_AFLAGS}"
# }}}
if [ -e ~/.bashlocal ]; then
. ~/.bashlocal
fi
## Here goes garbage forking stupid apps shitting their shits here:
#
# BEGIN_KITTY_SHELL_INTEGRATION
if test -n "$KITTY_INSTALLATION_DIR" -a -e "${KITTY_INSTALLATION_DIR}/shell-integration/bash/kitty.bash"; then source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"; fi
# END_KITTY_SHELL_INTEGRATION
# Instead of add ~/.dotfiles-site/linuxbrew.sh to /etc/bash.bashrc
# if [ -d /home/linuxbrew/.linuxbrew/share/applications ]; then
# if [ -n "${XDG_DATA_DIRS}" ]; then
# export XDG_DATA_DIRS="/home/linuxbrew/.linuxbrew/share:${XDG_DATA_DIRS}"
# else
# export XDG_DATA_DIRS="/home/linuxbrew/.linuxbrew/share"
# fi
# fi
export HOMEBREW_NO_ANALYTICS=1
# >>> Scala coursier install directory >>>
[ -d "${HOME}/.local/share/coursier/bin" ] && export PATH="$PATH:${HOME}/.local/share/coursier/bin"
# <<< coursier install directory <<<