Cleanup and improve .bashrc.

This commit is contained in:
2025-10-09 23:22:09 +13:00
parent 4ee8c17fad
commit f89791d7ff

45
.bashrc
View File

@ -1,40 +1,42 @@
# ==============================================================================
# Personal $HOME/.bashrc file by James Blair <mail@jamesblair.net>
# ==============================================================================
# If not running interactively, don't do anything # If not running interactively, don't do anything
[ -z "$PS1" ] && return [ -z "$PS1" ] && return
# don't put duplicate lines or lines starting with space in the history. # Don't put duplicate lines or lines starting with space in the history.
HISTCONTROL=ignoreboth HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it # Append to the history file, don't overwrite it
# also ensure we write to history immediately instead of only on terminal close # Also ensure we write to history immediately instead of only on terminal close
shopt -s histappend shopt -s histappend
export PROMPT_COMMAND="history -a; history -n" export PROMPT_COMMAND="history -a; history -n"
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) # Retain infinite bash history
HISTSIZE=10000 HISTSIZE=-1
HISTFILESIZE=20000 HISTFILESIZE=-1
# check the window size after each command and, if necessary, # Check the window size after each command and, if necessary
# update the values of LINES and COLUMNS. # update the values of LINES and COLUMNS.
shopt -s checkwinsize shopt -s checkwinsize
# enable color support of ls and also add handy aliases # Alias ls to eza
if [ -x /usr/bin/dircolors ]; then if [ "$(command -v eza)" ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" alias ll='eza -l --icons=auto --group-directories-first'
alias ls='ls -l --color=auto -h --group-directories-first' alias ls='eza -l --icons=auto --group-directories-first'
alias ll='ls -l --color=auto -h --group-directories-first' fi
# Alias cat to bat
if [ "$(command -v bat)" ]; then
alias cat='bat --style=plain --pager=never' 2>/dev/null
fi fi
# Alias docker to podman # Alias docker to podman
alias docker=podman alias docker=podman
# Custom git alias for pushing to all remotes at once # Alias df to dysk
alias gpa='git remote | xargs -L1 git push --all' if [ "$(command -v bat)" ]; then
alias df=dysk
fi
# simplify bitwarden cli usage # Simplify bitwarden cli usage
cpcmd="xclip -selection c"; if [[ "$XDG_SESSION_TYPE" == "wayland" ]]; then cpcmd="wl-copy"; fi cpcmd="xclip -selection c"; if [[ "$XDG_SESSION_TYPE" == "wayland" ]]; then cpcmd="wl-copy"; fi
alias bwu='export BW_SESSION=$(bw unlock --raw > ~/.bw_session && cat ~/.bw_session)' alias bwu='export BW_SESSION=$(bw unlock --raw > ~/.bw_session && cat ~/.bw_session)'
@ -88,9 +90,7 @@ function bwai () {
bw encode | bw create item && bw sync bw encode | bw create item && bw sync
} }
# enable programmable completion features (you don't need to enable # Enable programmable completion features
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion . /usr/share/bash-completion/bash_completion
@ -167,6 +167,7 @@ alias bthsd="bluetoothctl disconnect CC:98:8B:B6:F0:8E"
# Add kubectl krew plugins to path # Add kubectl krew plugins to path
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH" export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
# Enable simple bash prompt
SBP_PATH=/home/james/Downloads/sbp SBP_PATH=/home/james/Downloads/sbp
source /home/james/Downloads/sbp/sbp.bash source /home/james/Downloads/sbp/sbp.bash