From 1aacb642be4fab0758d3356a0c7b5a8fac306fe1 Mon Sep 17 00:00:00 2001 From: Ahmed Abdelhalim Date: Sat, 17 Jan 2026 17:37:55 +0100 Subject: Create simpler bash_profile and move everything to bashrc This is more compatible with Linux and still works perfectly on the Mac --- .bash_profile | 149 ++++++---------------------------------------------------- 1 file changed, 14 insertions(+), 135 deletions(-) (limited to '.bash_profile') diff --git a/.bash_profile b/.bash_profile index 1bdacbc..94e087b 100644 --- a/.bash_profile +++ b/.bash_profile @@ -1,5 +1,15 @@ -#!/bin/bash -# shellcheck disable=SC1091 +#!/bin/bash +# shellcheck disable=SC1091 +# Disables file doesn't exist warning + +if [ -f "$HOME/.profile" ]; then + source "$HOME/.profile" +fi + +# *nix include bashrc if found and override here +if [ -f "$HOME/.bashrc" ]; then + source "$HOME/.bashrc" +fi # Homebrew Apple M1/Intel fixing of $PATH and loading bash_completion if [ -d /opt/homebrew ]; then @@ -10,138 +20,7 @@ elif [ -d /usr/local/Homebrew ]; then source "/usr/local/Homebrew/etc/bash_completion" fi -# *nix include bashrc if found and override here -if [ -f "$HOME/.bashrc" ]; then - source "$HOME/.bashrc" -fi - -export CLICOLOR=1 # Mac OS custorm colors (not LS_COLORS as unix) defaultscheme "exfxcxdxbxegedabagacad" export LSCOLORS=gxfxcxdxbxegedabagacad -export BASH_SILENCE_DEPRECATION_WARNING=1 # Silence new macOS warning about bash -# Unix/Bash Readline custom colors (created by dircolors in bashrc) -export LS_COLORS="$LS_COLORS:di=00;36:ln=00;35:ex=00;31" - -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="[\h]: \W \$ " -export LC_ALL=en_US.UTF-8 -export LANG=en_US.UTF-8 - -# ==== GPG Config -GPG_TTY=$(tty) -export GPG_TTY -unset SSH_AGENT_PID - -# macOS locally: SSH_AUTH_SOCK is empty (FALSE) || SSH_CONNECTION is empty (TRUE) = uses gpg-agent -# Linux locally: SSH_AUTH_SOCK might be empty (TRUE) || SSH_CONNECTION is empty (TRUE) = uses gpg-agent -# SSH session: SSH_AUTH_SOCK is empty (FALSE) || SSH_CONNECTION is empty (FALSE) = keep forwarded agent -if [ -z "$SSH_AUTH_SOCK" ] || [ -z "$SSH_CONNECTION" ]; then - SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) - export SSH_AUTH_SOCK -fi - -# ==== 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' -alias hi!='fortune | cowsay | lolcat' - -# ==== 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 - -# ==== include local bin in path -if [ -d "$HOME/.local/bin" ]; then - export PATH="$HOME/.local/bin:$PATH" -fi - -# ==== go config. -if command -v go 1>/dev/null 2>&1; then - export PATH="$HOME/go/bin:$PATH" -fi - -# ==== rust config -if command -v cargo 1>/dev/null 2>&1; then - source "$HOME/.cargo/env" -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 -if [ -f "$HOME/.nvm/nvm.sh" ]; then - export NVM_DIR=~/.nvm - source "$HOME/.nvm/nvm.sh" -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 - -# ==== 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 -} +# Silence new macOS warning about bash +export BASH_SILENCE_DEPRECATION_WARNING=1 -- cgit v1.2.3