bashrc.d§ 

my .bashrc

for i in "${HOME}/.bashrc.d"/[0-9][0-9]-*.bashrc; do
  if [ -r "$i" ]; then
    . "$i"
  fi
done
unset i

my actual config:

$ tree .bashrc.d
.bashrc.d
├── 00-default.bashrc
├── 05-prompt.bashrc
├── 05-ssh.bashrc
├── 10-alias.bashrc
├── 10-functions.bashrc
├── 20-nnn.bashrc
└── 20-task.bashrc

1 directory, 7 files

default§ 

# https://askubuntu.com/questions/1352436/tmux-history-not-preserved
HISTCONTROL=ignoredups:erasedups # avoid dupes
shopt -s histappend  # append instead of overwriting
# append to history and reread after each command
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"

[[ $- != *i* ]] && return # if not running interactively, don't do anything
shopt -s autocd # change dir using name only
bind 'set completion-ignore-case on' # ignore case for completion

# exports
export EDITOR=kak
export BROWSER=w3m
export NNN_TRASH=1
export NNN_OPENER=nuke
export NO_COLOR=0
export PATH=$PATH:$HOME/.local/bin

# check if a tmux session is running and create one if not
if [[ ! $(tmux list-sessions) ]]; then
  tmux
fi

old prompt§ 

# https://unix.stackexchange.com/questions/26844/abbreviated-current-directory-in-shell-prompt

PROMPT_COMMAND='PS1X=$(p="${PWD#${HOME}}"; [ "${PWD}" != "${p}" ] && printf "~";IFS=/; for q in ${p:1}; do printf /${q:0:1}; done; printf "${q:1}")'
PS1='\u@\h ${PS1X} :: '

# or

PROMPT_COMMAND='PS1_PATH=$(sed "s:\([^/\.]\)[^/]*/:\1/:g" <<< ${PWD/#$HOME/\~})'

git prompt§ 

function parse_git_dirty {
  [[ $(git status --porcelain 2> /dev/null) ]] && echo "*"
}
function parse_git_branch {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ (\1$(parse_git_dirty))/"
}

export PS1="\n \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
#https://code.mendhak.com/simple-bash-prompt-for-developers-ps1-git/

integrations§ 

nnn§ 

# https://github.com/jarun/nnn/wiki/Basic-use-cases#configure-cd-on-quit
# https://github.com/jarun/nnn/blob/master/misc/quitcd/quitcd.bash_sh_zsh
n ()
{
    # Block nesting of nnn in subshells
    [ "${NNNLVL:-0}" -eq 0 ] || {
        echo "nnn is already running"
        return
    }

    # The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set)
    # If NNN_TMPFILE is set to a custom path, it must be exported for nnn to
    # see. To cd on quit only on ^G, remove the "export" and make sure not to
    # use a custom path, i.e. set NNN_TMPFILE *exactly* as follows:
    #      NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
    export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"

    # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
    # stty start undef
    # stty stop undef
    # stty lwrap undef
    # stty lnext undef

    # The command builtin allows one to alias nnn to n, if desired, without
    # making an infinitely recursive alias
    command nnn -Rd "$@"

    [ ! -f "$NNN_TMPFILE" ] || {
        . "$NNN_TMPFILE"
        rm -f -- "$NNN_TMPFILE" > /dev/null
    }
}


ssh§ 

# https://stackoverflow.com/questions/18880024/start-ssh-agent-on-login
if [ ! -S ~/.ssh/ssh_auth_sock ]; then
  eval `ssh-agent`
  ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
fi
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
ssh-add -l > /dev/null || ssh-add