-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbash_config
More file actions
executable file
·148 lines (122 loc) · 4.59 KB
/
bash_config
File metadata and controls
executable file
·148 lines (122 loc) · 4.59 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
# Useful variables
OS=$(uname)
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
export BASH_SILENCE_DEPRECATION_WARNING=1
# This adds color to man pages
export PAGER="most"
# Add Nvim as the default editor
export EDITOR=nvim
export CVSEDITOR=nvim
export SVN_EDITOR=nvim
# setup $PATH unless $TMUX is set
if [[ -z $TMUX ]]; then
export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/sbin:$PATH
export PATH=/usr/local/share/npm/bin:$PATH
export PATH=/opt/homebrew/bin:$PATH
export PATH=$PATH:/usr/bin/vendor_perl
export PATH=$PATH:$HOME/Documents/bin
export PATH=$PATH:.
fi
# Android SDK config
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
# Force Java 17 for Android Builds
export JAVA_HOME=$(/usr/libexec/java_home -v 17)
# setup ruby version manager
[[ -d $HOME/.rbenv ]] && source $HOME/.rbenvrc
# setup node version 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
# automatically use current nvm version if nvmrc exists
cdnvm() {
command cd "$@" || return $?
nvm_path="$(nvm_find_up .nvmrc | command tr -d '\n')"
# If there are no .nvmrc file, use the default nvm version
if [[ ! $nvm_path = *[^[:space:]]* ]]; then
declare default_version
default_version="$(nvm version default)"
# If there is no default version, set it to `node`
# This will use the latest version on your machine
if [ $default_version = 'N/A' ]; then
nvm alias default node
default_version=$(nvm version default)
fi
# If the current version is not the default version, set it to use the default version
if [ "$(nvm current)" != "${default_version}" ]; then
nvm use default
fi
elif [[ -s "${nvm_path}/.nvmrc" && -r "${nvm_path}/.nvmrc" ]]; then
declare nvm_version
nvm_version=$(<"${nvm_path}"/.nvmrc)
declare locally_resolved_nvm_version
# `nvm ls` will check all locally-available versions
# If there are multiple matching versions, take the latest one
# Remove the `->` and `*` characters and spaces
# `locally_resolved_nvm_version` will be `N/A` if no local versions are found
locally_resolved_nvm_version=$(nvm ls --no-colors "${nvm_version}" | command tail -1 | command tr -d '\->*' | command tr -d '[:space:]')
# If it is not already installed, install it
# `nvm install` will implicitly use the newly-installed version
if [ "${locally_resolved_nvm_version}" = 'N/A' ]; then
nvm install "${nvm_version}";
elif [ "$(nvm current)" != "${locally_resolved_nvm_version}" ]; then
nvm use "${nvm_version}";
fi
fi
}
alias cd='cdnvm'
cdnvm "$PWD" || exit
# Regular Colors
txtrst='\e[0m' # Text Reset
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
Cyan='\e[0;36m' # Cyan
White='\e[0;37m' # White
PS1="\n${Yellow}[${txtrst} \h-${Green}\u${txtrst} \w\$(__git_ps1) ${Yellow}]${txtrst}\n $ "
# Enable use of git in the shell environment/prompt
. /opt/homebrew/etc/bash_completion.d/git-completion.bash
. /opt/homebrew/etc/bash_completion.d/git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=true
# Enable use of pass
. $HOME/.dotfiles/pass-completion.bash
# Aliases to make the CLI a little easier to handle
alias cs="clear"
alias cdcs="cd ~ && clear"
alias cscd="cd ~ && clear"
alias grep="grep --color=auto"
alias df="df -h"
alias du="du -shc"
alias lll="tree -h"
alias top="htop"
alias gstat="git status"
alias gdiff="git diff"
alias ghist="git log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short"
alias dot_clean="find /home -name '._*' -exec rm {} \;"
if [ $OS == "Darwin" -o $OS == "FreeBSD" ]; then
alias ls="ls -hG"
alias ll="ls -hlG"
alias la="ls -hlaG"
else
alias ls="ls -h --color=always --group-directories-first"
alias ll="ls -hl --color=always --group-directories-first"
alias la="ls -hla --color=always --group-directories-first"
fi
# setup solarized dircolors
if [ $OS != "Darwin" ]; then
eval `dircolors ~/.dotfiles/dircolors/dircolors.ansi-dark`
fi
# Enable tab completion with sudo
complete -cf sudo
# add ssh identities for ForwardAgent
ssh-add > /dev/null 2>&1
# Enable tab completion with ssh
[[ -e $HOME/.ssh/config ]] && complete -o 'default' -o 'nospace' -W '$(grep ^Host ~/.ssh/config | grep -v [?*] | cut -d " " -f2)' scp sftp ssh