-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_bashrc
More file actions
200 lines (170 loc) · 7.28 KB
/
Copy pathdot_bashrc
File metadata and controls
200 lines (170 loc) · 7.28 KB
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
#-------------------------------------------------------------------------------
# ~/.bashrc
#-------------------------------------------------------------------------------
# (1) Defining Aliases and Functions: Setting up shortcuts and custom commands
# that are useful for interactive use but are not environment variables
# (2) Customizing the Prompt: Modifying the appearance and information
# displayed in your shell prompt (e.g., PS1).
# (3) Interactive Settings: Configuring features specific to interactive use,
# such as command-line completion settings
#-------------------------------------------------------------------------------
# If not running interactively, don't do anything
case $- in *i*) ;; *) return;; esac
# This is to due to the "Bash invoked by remote shell daemon" special case. See
# https://unix.stackexchange.com/a/257613 if you need a refresher.
# TODO: What was I on about here?
# If this needs to be guarded against non-interctive shells then that
# feels like a sign I shouldn't source .bashrc from .bash_profile
# as I've been thinking about
# if [ -t 1 ]; then
# bind 'set show-all-if-ambiguous on'
# bind 'TAB:menu-complete'
# bind 'set print-completions-horizontally on'
# fi
# TODO: if something that feels like this may be the issue hasn't bitten you in
# quite some time you should go ahead and delete this block
#-------------------------------------------------------------------------------
# "Interactive Bash" Config
#-------------------------------------------------------------------------------
shopt -s globstar
export HISTCONTROL=ignoreboth
# ignoreboth: shorthand for ‘ignorespace’ and ‘ignoredups
# ignorespace: lines beginning with a space are not saved
# ignoredups: lines which match the previous history entry to not be saved
export HISTFILESIZE=2048 #~4x from a default of 500
shopt -s histappend
#-------------------------------------------------------------------------------
# aliases
#-------------------------------------------------------------------------------
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
# Handle color between macOS and Linux. Might bite me on BSD one day...
if [[ $OSTYPE =~ darwin.* ]]; then
if command -v gls &> /dev/null; then
alias ls='gls -F --color=auto'
alias l1='gls -1F --color=auto'
alias ll='gls -Fhl --color=auto'
alias la='gls -AF --color=auto'
alias lal='gls -AFhl --color=auto'
alias la1='gls -1AFh --color=auto'
else
alias ls='ls -FG'
alias l1='ls -1FG'
alias ll='ls -FGhl'
alias la='ls -AFG'
alias lal='ls -AFGhl'
alias la1='ls -1AFGh'
fi
elif [[ $OSTYPE =~ linux.* ]]; then
alias ls='ls -F --color=auto'
alias l1='ls -1F --color=auto'
alias ll='ls -Fhl --color=auto'
alias la='ls -AF --color=auto'
alias lal='ls -AFhl --color=auto'
alias la1='ls -1AFh --color=auto'
fi
# TODO: consider if you want to keep this or specify unstable in justfiles
alias just='just --unstable'
# TODO: decide if you really to keep these around
if [[ $OSTYPE =~ darwin.* ]]; then
alias chrome='open -a /Applications/Google\ Chrome.app'
alias firefox='open -a /Applications/Firefox.app'
alias safari='open -a /Applications/Safari.app'
fi
#-------------------------------------------------------------------------------
# Starship [https://starship.rs/]
# and PS1 fallback
#-------------------------------------------------------------------------------
if command -v starship &> /dev/null ; then
eval "$(starship init bash)"
STARSHIP=true
else
STARSHIP=false
if [[ -z $(type -t __git_ps1) ]]; then
source $(brew --prefix)/etc/bash_completion.d/git-prompt.sh
fi
# unstaged (*) and staged (+) changes will be shown next to the branch name
GIT_PS1_SHOWDIRTYSTATE=true
# If something is stashed, then a '$' will be shown next to the branch name.
GIT_PS1_SHOWSTASHSTATE=true
# If there're untracked files, then a '%' will be shown next to the branch name.
GIT_PS1_SHOWUNTRACKEDFILES=true
# see the difference between HEAD and its upstream. A "<" indicates you are
# behind, ">" indicates you are ahead, "<>" indicates you have diverged and "="
# indicates that there is no difference. Adding "verbose" shows number of
# commits ahead/behind (+/-) upstream
GIT_PS1_SHOWUPSTREAM="auto verbose"
# The prompt will include "|CONFLICT" when there are unresolved conflicts
GIT_PS1_SHOWCONFLICTSTATE=yes
# colored hint about the current dirty state
GIT_PS1_SHOWCOLORHINTS=true
if [[ -f ~/.cloudinstance ]]; then
n=$(<~/.cloudinstance)
export PS1='[\e[94m\u\e[0m\e[34m@\e[0m\e[94m$n\e[0m | \e[95m\w\e[0m$(__git_ps1 " | %s")]\n$ '
else
export PS1='[\e[94m\u\e[0m\e[34m@\e[0m\e[94m\h\e[0m | \e[95m\w\e[0m$(__git_ps1 " | %s")]\n$ '
fi
fi
#-------------------------------------------------------------------------------
# brew [https://brew.sh/]
#-------------------------------------------------------------------------------
if [[ $OSTYPE =~ darwin.* ]] && [[ -d /opt/homebrew ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
HOMEBREW_PREFIX="$(brew --prefix)"
elif [[ $OSTYPE =~ linux.* ]] && [[ -d /home/linuxbrew/.linuxbrew ]]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
HOMEBREW_PREFIX="$(brew --prefix)"
else
echo "BASHRC: brew not configured"
fi
if [[ -n "$HOMEBREW_PREFIX" ]]; then
[[ -r "$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh" ]] && . "$HOMEBREW_PREFIX/etc/profile.d/bash_completion.sh"
MANPATH="$HOMEBREW_PREFIX/share/man:$MANPATH"
fi
#-------------------------------------------------------------------------------
# fzf [https://github.com/junegunn/fzf]
#-------------------------------------------------------------------------------
if command -v fzf &> /dev/null; then
# Set up fzf key bindings and fuzzy completion
eval "$(fzf --bash)"
export FZF_DEFAULT_OPTS="--color=base16"
else
echo "BASHRC: fzf binary not found"
fi
#-------------------------------------------------------------------------------
# rbenv [https://rbenv.org/]
# ruby [https://www.ruby-lang.org/]
#-------------------------------------------------------------------------------
if command -v rbenv &> /dev/null; then
eval "$(rbenv init - --no-rehash bash)"
MANPATH="$(rbenv prefix)/share/man:$MANPATH"
else
echo "BASHRC: rbenv binary not found"
fi
#-------------------------------------------------------------------------------
# rust [https://www.rust-lang.org/]
#-------------------------------------------------------------------------------
if [[ -f $HOME/.cargo/env ]]; then
. "$HOME/.cargo/env"
else
echo "BASHRC: cargo not configured"
fi
#-------------------------------------------------------------------------------
# zoxide [https://github.com/ajeetdsouza/zoxide]
#-------------------------------------------------------------------------------
if command -v zoxide &> /dev/null; then
eval "$(zoxide init bash)"
else
echo "BASHRC: zoxide binary not found"
fi
#-------------------------------------------------------------------------------
# direnv [https://direnv.net/]
# "Make sure it appears even after rvm, git-prompt and other shell extensions
# that manipulate the prompt."
#-------------------------------------------------------------------------------
if command -v direnv &> /dev/null; then
eval "$(direnv hook bash)"
else
echo "BASHRC: direnv not found"
fi