summaryrefslogtreecommitdiffstats
path: root/.bash_profile
blob: f7ee1eaf7e3ce8d6b43fe7e7eabdaadc4c5b3ed3 (plain) (blame)
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
#!/bin/bash
# ==== Homebrew Apple M1/Intel fixing of $PATH
if [ -d /opt/homebrew ]; then
  eval "$(/opt/homebrew/bin/brew shellenv)"
elif [ -d /usr/local/Homebrew ]; then
  eval "$(/usr/local/Homebrew/bin/brew shellenv)"
fi

export CLICOLOR=1
export LSCOLORS=gxfxcxdxbxegedabagacad # Mac OS custorm colors (not LS_COLORS as unix) defaultscheme "exfxcxdxbxegedabagacad"
export LS_COLORS="$LS_COLORS:di=00;36:ln=00;35:ex=00;31" # Unix/Bash Readline custom colors
export IGNOREEOF=42 # Ignore Ctrl+D logout terminal session
export HISTSIZE=1000 # Num commands to remmember in a terminal session
export HISTFILESIZE=10000 # Max number of linse in history file
export HISTFILE="$HOME/.bash_history"
export HISTCONTROL=ignoredups:erasedups
export EDITOR='vim'
export TERM="xterm-256color"
export GREP_OPTIONS="--color=auto"
export PS1="[\u]: \W \$ "
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
GPG_TTY=$(tty)
export GPG_TTY
unset SSH_AGENT_PID
SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
export SSH_AUTH_SOCK
export BASH_SILENCE_DEPRECATION_WARNING=1 # Silence new macOS warning about bash
export USE_GKE_GCLOUD_AUTH_PLUGIN=True

# ==== Shell Opts
shopt -s checkwinsize  # check the window size after each command and, if necessary, update LINES/COLUMNS

# ==== Aliases
alias spc="cd ~/Work/Space/"
alias mb="cd ~/Work/MBition/"
alias la='ls -a'
alias dirs="dirs -v"
alias srv="python3 -m http.server" # start simple server
alias tagme='ctags -R --languages=ruby --exclude=.git --exclude=log . $(bundle list --paths)'
alias gpgkill='(
  pkill pinentry-tty
  pkill pinentry-curses
  gpg-connect-agent killagent /bye
  gpg-connect-agent updatestartuptty /bye
  gpg-connect-agent /bye
)'
alias cgit='docker run --name cgit -v $(pwd):/srv -p 1313:80 --rm -it cgit'

# ==== Functions
# get app ID to add to amethyst (example appid /Applications/Spotify.app/)
appid() {
  codesign -dr - "$@"
}

homebrew_token() {
  HOMEBREW_GITHUB_API_TOKEN=$(pass personal/github | grep homebrew_token | awk '{ print $NF}')
  export HOMEBREW_GITHUB_API_TOKEN
}

if command -v neomutt 1>/dev/null 2>&1; then
  # Fixes the pinentry-tty error https://github.com/neomutt/neomutt/issues/1014
  mutt() {
    PINENTRY_USER_DATA=curses neomutt "$@"
  }
fi

# ==== go config.
if command -v go 1>/dev/null 2>&1; then
  export PATH="$HOME/go/bin:$PATH"
fi

# ==== rbenv config.
if command -v rbenv 1>/dev/null 2>&1; then
  export PATH="$HOME/.rbenv/bin:$PATH"
  eval "$(rbenv init -)"
fi

# ==== NVM config
# shellcheck source=/dev/null
if [ -f "$HOME/.nvm/nvm.sh" ]; then
  export NVM_DIR=~/.nvm
  source "$HOME/.nvm/nvm.sh"
fi

# ==== Vault completeion
if command -v vault 1>/dev/null 2>&1; then
  complete -C "$(brew --prefix)/bin/vault" vault
fi

# ==== Generate helm autocomplete stuff when it's not there
if command -v helm 1>/dev/null 2>&1; then
  if [ ! -f "$(brew --prefix)/etc/bash_completion.d/helm" ]; then
     helm completion bash > "$(brew --prefix)/etc/bash_completion.d/helm"
  fi
fi

# ==== Generate podman completion script when it's not there
if command -v podman 1>/dev/null 2>&1; then
  if [ ! -f "$(brew --prefix)/etc/bash_completion.d/podman" ]; then
    podman completion bash > "$(brew --prefix)/etc/bash_completion.d/podman"
  fi
fi

# ==== k8s/ktx/kns completeion
if command -v kubectl 1>/dev/null 2>&1; then
  alias k='kubectl'
  complete -F __start_kubectl k
  alias ktx='kubectx'
  complete -F _kube_contexts ktx
  alias kns='kubens'
  complete -F _kube_namespaces kns
fi

# ==== zoxide (smarter cd command)
if command -v zoxide 1>/dev/null 2>&1; then
  eval "$(zoxide init bash --cmd cd)"
fi

# ==== load all bash completions
if [ -f "$(brew --prefix)/etc/bash_completion" ]; then
  . "$(brew --prefix)/etc/bash_completion"
fi

# ==== MISC CowSay
# fortune | cowsay | lolcat

# ==== Work config ===========================================================
# ==== Aliases
alias assume=". assume"

# ==== Functions
gitlab_token() {
  GITLAB_TOKEN=$(pass mbition/git | grep token | awk '{ print $NF}')
  export GITLAB_TOKEN
}
gitlab_su_token() {
  GITLAB_TOKEN=$(pass mbition/git | grep su_token | awk '{ print $NF}')
  export GITLAB_TOKEN
}
gitlab_baas_token() {
  GITLAB_TOKEN=$(pass mbition/git | grep baas_token | awk '{ print $NF}')
  export GITLAB_TOKEN
}


# ==== JAVA Config
if command -v java 1>/dev/null 2>&1; then
  export PATH="$(brew --prefix)/opt/openjdk@11/bin:$PATH"
  export PATH="$(brew --prefix)/opt/gradle@6/bin:$PATH"
fi

# ==== JFrog CLI config
if command -v jf 1>/dev/null 2>&1; then
  _jfrog() {
    local cur opts
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    opts=$( "${COMP_WORDS[@]:0:$COMP_CWORD}" --generate-bash-completion )
    mapfile -t COMPREPLY < <(compgen -W "${opts}" -- "${cur}")
  }
  complete -F _jfrog -o default jfrog
  complete -F _jfrog -o default jf
fi

# ==== CLang and Sphinx doc config
if command -v clang-format 1>/dev/null 2>&1; then
  export PATH="$(brew --prefix)/opt/sphinx-doc/bin:$PATH"
fi