summaryrefslogtreecommitdiffstats
path: root/.bash_profile
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2025-10-20 16:39:58 +0200
committerAhmed Abdelhalim <[email protected]>2025-10-20 16:42:10 +0200
commit08e817eeb0d62dc8afc8dbd416971b68854036b2 (patch)
treea76fe5713e00a8c55a76c8122c868978a4b72b2b /.bash_profile
parenta0f646e8c14db26eb13f8336a7cc8937d9c476b2 (diff)
Refactoring of bash_profile and remove deprecated homebrew token
The token didn't have any permissions, was used to just increase the rate limit when it was reached. This is why it's ok to leave it in the history after it has been revoked. This also fixes and adds some dependencies using homebrew
Diffstat (limited to '.bash_profile')
-rw-r--r--.bash_profile83
1 files changed, 50 insertions, 33 deletions
diff --git a/.bash_profile b/.bash_profile
index 8121b2f..8dfcfc5 100644
--- a/.bash_profile
+++ b/.bash_profile
@@ -1,3 +1,4 @@
+#!/bin/bash
# ==== Homebrew Apple M1/Intel fixing of $PATH
if [ -d /opt/homebrew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
@@ -10,21 +11,22 @@ export CLICOLOR=1
# Mac OS custorm colors (not LS_COLORS as unix)
export LSCOLORS=gxfxcxdxbxegedabagacad
# Unix/Bash Readline custom colors
-export LS_COLORS=$LS_COLORS:"di=00;36:ln=00;35:ex=00;31"
+export LS_COLORS="$LS_COLORS:di=00;36:ln=00;35:ex=00;31"
-export HISTSIZE=2000 # History size
+export HISTSIZE=20000 # History size
export IGNOREEOF=42 # Ignore Ctrl+D logout terminal session
-export HISTCONTROL=erasedups # remove consecutive history entries
+export HISTCONTROL=ignoredups:erasedups # remove consecutive history entries
export EDITOR='vim' # Default editor
export TERM="xterm-256color"
export GREP_OPTIONS="--color=auto"
-export HOMEBREW_GITHUB_API_TOKEN="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"
export PS1="[a14m] \W \$ "
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
-export GPG_TTY=$(tty)
+GPG_TTY=$(tty)
+export GPG_TTY
unset SSH_AGENT_PID
-export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
+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
@@ -43,27 +45,28 @@ alias gpgkill='(
)'
alias cgit='docker run --name cgit -v $(pwd):/srv -p 1313:80 --rm -it cgit'
-# alias g='git'
-# # look up the original completion command and replace the last with the alias
-# complete -o bashdefault -o default -o nospace -F __git_wrap__git_main g
-
# ==== Functions
-# get app ID to add to amethyst (apps have to be running)
-function appid {
+# 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
+}
+
# ==== Aliased Directories
alias rc="cd ~/.rc"
alias spc="cd ~/Work/Space/"
alias mb="cd ~/Work/MBition/"
-alias htb="cd ~/Work/HTB/"
-alias otw="cd ~/Work/OTW/"
alias obs="cd ~/Library/Mobile\ Documents/iCloud~md~obsidian/Documents/Vault/MBition/"
if command -v neomutt 1>/dev/null 2>&1; then
# Fixes the pinentry-tty error https://github.com/neomutt/neomutt/issues/1014
- alias mutt='PINENTRY_USER_DATA=curses neomutt $@'
+ mutt() {
+ PINENTRY_USER_DATA=curses neomutt "$@"
+ }
fi
# ==== go config.
@@ -91,40 +94,40 @@ if command -v pipx 1>/dev/null 2>&1; then
fi
# ==== Rust config
-if [ -f $HOME/.cargo/env ]; then
+if [ -f "$HOME/.cargo/env" ]; then
source "$HOME/.cargo/env"
fi
# ==== NVM config
# node version manager from homebrew ,the source line to move install location
# and prevent Node installs being lost upon upgrading nvm.
-if [ -f $(brew --prefix nvm)/nvm.sh ]; then
+if [ -f "$(brew --prefix nvm)/nvm.sh" ]; then
export NVM_DIR=~/.nvm
- source $(brew --prefix nvm)/nvm.sh
+ source "$(brew --prefix nvm)/nvm.sh"
fi
# ==== MISC config
if command -v thefuck 1>/dev/null 2>&1; then
# allow fuck to be alias of thefuck
- eval $(thefuck --alias)
+ eval "$(thefuck --alias)"
fi
# ==== Vault completeion
if command -v vault 1>/dev/null 2>&1; then
- complete -C $(brew --prefix)/bin/vault vault
+ 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
+ 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
+ if [ ! -f "$(brew --prefix)/etc/bash_completion.d/podman" ]; then
+ podman completion bash > "$(brew --prefix)/etc/bash_completion.d/podman"
fi
fi
@@ -138,13 +141,18 @@ if command -v kubectl 1>/dev/null 2>&1; then
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
+if [ -f "$(brew --prefix)/etc/bash_completion" ]; then
+ . "$(brew --prefix)/etc/bash_completion"
fi
# ==== MISC CowSay
-fortune | cowsay | lolcat
+# fortune | cowsay | lolcat
# ==== Work config ===========================================================
@@ -160,11 +168,11 @@ fi
# ==== JFrog CLI config
if command -v jf 1>/dev/null 2>&1; then
_jfrog() {
- local cur opts base
+ local cur opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
- opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ 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
@@ -176,6 +184,15 @@ if command -v clang-format 1>/dev/null 2>&1; then
fi
alias assume=". assume"
-alias glab_assume="export GITLAB_TOKEN=$(pass mbition/git | grep token | awk '{ print $NF}')"
-alias glab_su_assume="export GITLAB_TOKEN=$(pass mbition/git | grep su_token | awk '{ print $NF}')"
-alias glab_baas_assume="export GITLAB_TOKEN=$(pass mbition/git | grep baas_token | awk '{ print $NF}')"
+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
+}