bash_profile @ 8e22b36e5cba

More
author Steve Losh <steve@stevelosh.com>
date Wed, 17 Jul 2024 15:51:26 -0400
parents cf74bfa5845a
children (none)
#!/usr/bin/env bash

if test -e /etc/profile; then
    source /etc/profile
fi

shopt -s expand_aliases
shopt -s histappend
shopt -s checkwinsize

# Save multiline commands as a single history entry.
shopt -s cmdhist

HISTFILESIZE=100000
HISTSIZE=100000
HISTCONTROL=ignoreboth

# Flush commands to history immediately instead of waiting for logout.
PROMPT_COMMAND='history -a'

if test -e ~/.dircolors; then
    eval "$(dircolors -b ~/.dircolors)"
fi

D=$'\x01\e[37m\x02'
RED=$'\x01\e[31m\x02'
GREEN=$'\x01\e[32m\x02'
ORANGE=$'\x01\e[33m\x02'
BLUE=$'\x01\e[34m\x02'
PINK=$'\x01\e[35m\x02'
# CYAN=$'\e[36m'

function last_return_value() {
    x="$?"
    if test "$x" -ne 0; then
        echo -n "${RED}[$x] ${D}"
    fi
}

function histgrep {
    history | grep "$@" | tac | f 2-
}

if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
  HOST_COLOR="$BLUE"
else
  HOST_COLOR="$ORANGE"
fi

export PS1='\n${PINK}\u ${D}at ${HOST_COLOR}\h ${D}in ${GREEN}\w${D} $(last_return_value)$ '

alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ......="cd ../../../../.."

function mcd {
    mkdir "$1" && cd "$1"
}

alias js='cd ~/scratch'

alias :q=exit
alias :qa=exit
alias :wqa=exit

if command -v ag >/dev/null; then
    AG_BIN="$(command -v ag)"
    function ag() {
        if test -f '.agignore' && grep -q 'pragma: skipvcs' '.agignore'; then
            $AG_BIN --search-files -U "$@"
        else
            $AG_BIN --search-files "$@"
        fi
    }
fi

function prepend_to_path {
    if test -d "$1"; then
        PATH="$1":"$PATH"
    fi
}

PATH="/sbin"
prepend_to_path "/bin"
prepend_to_path "/usr/bin"
prepend_to_path "/usr/sbin"
prepend_to_path "/usr/local/bin"
prepend_to_path "/usr/local/sbin"
prepend_to_path "/usr/local/go/bin"
prepend_to_path "/usr/games"
prepend_to_path "/snap/bin"
prepend_to_path "$HOME/.local/bin"
prepend_to_path "$HOME/.go/bin"
prepend_to_path "$HOME/src/dotfiles/lisp/bin"
prepend_to_path "$HOME/src/dotfiles/bin"
prepend_to_path "$HOME/src/hg"
prepend_to_path "$HOME/bin"
export PATH

export LESS_TERMCAP_mb=$(printf '\e[01;31m')       # begin blinking
export LESS_TERMCAP_md=$(printf '\e[01;38;5;74m')  # begin bold
export LESS_TERMCAP_me=$(printf '\e[0m')           # end mode
export LESS_TERMCAP_se=$(printf '\e[0m')           # end standout-mode
export LESS_TERMCAP_so=$(printf '\e[38;5;246m')    # begin standout-mode - info box
export LESS_TERMCAP_ue=$(printf '\e[0m')           # end underline
export LESS_TERMCAP_us=$(printf '\e[04;38;5;146m') # begin underline
export PAGER='less -iX'

function psg() {
    ps auxww | grep --color=always "$@" | grep -v grep | collapse | cuts -f 2,11-
}

GPG_TTY=$(tty)
export GPG_TTY

export EDITOR=nvim

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

export PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig"