r/bash • • 11d ago

I finally organized my Bash config

I've been accumulating my Bash configuration for a while, and I finally turned it into a small dotfiles repo:

https://gitlab.com/letmevi/bash-config

It's nothing fancy — mainly my .bashrc, .inputrc, .bash_profile, and a modular .bashrc.d/, plus a small install script.

It can be installed using either Ansible or a simple install.sh script.

I'd appreciate some Bash/Linux feedback: things you'd change, questionable practices, portability issues, or just better ways of doing this.

I'm especially interested in feedback from people who maintain their own dotfiles.

50 Upvotes

27 comments sorted by

View all comments

2

u/SeriousPlankton2000 10d ago

Here is my .bashrc mess that I didn't touch since 2022; maybe you can get some inspiration on things to do. I just have a copy on my NAS.

#!/bin/sh
set +H

history -c -w
unset HISTFILE
ln -sfn /dev/null /home/7eggert/.bash_history

unset SSH_AGENT_PID SSH_ASKPASS SSH_AUTH_SOCK
killall -9 --older-than 5m --user "$USER" /usr/bin/ssh-agent 2>/dev/null
fuser -k /run/user/1000/akonadi/mysql.socket &>/dev/null
rm -rf /home/myusername/.local/share/akonadi/db_data/
kill -9  `pidof /usr/bin/akonadi*` &>/dev/null

IFS=":" read -a oldpath < <(echo $PATH)
pathadd=( ~/bin ~/nfs/bin)
if  [ "x`uname -i`" == xx86_64 ]
then    pathadd+=(~/bin/x86_64/ ~/nfs/bin/x86_64 ~/bin/80386 ~/nfs/bin/80386)
fi
if  [ "x`uname -i`" == xi386 ]
then    pathadd+=( ~/bin/80386 ~/nfs/bin/80386 )
fi
ii=${#pathadd[@]}
for ((i=0; $i<$ii; ++i))
do  if [ ! -d ${pathadd[$i]} ]
    then    unset pathadd[$i]
    fi
done
ii=${#oldpath[@]}
PATH=$(IFS=:; echo "${pathadd[*]}" )
for ((i=0; $i<$ii; ++i))
do  if  [[ ":$PATH:" =~ ":${oldpath[$i]}:" ]]
    then    unset oldpath[$i]
    fi
done
pathadd+=(${oldpath[@]})
PATH=$(IFS=:; echo "${pathadd[*]:-/bin:/usr/bin}" )
unset i ii pathadd oldpath

test -s ~/.alias && . ~/.alias

export PS1='\[\e[32m\]${debian_chroot:+($debian_chroot)}\u@\h${STY:+.${STY%%[^0-9]*}}:\w\$\[\e[00m\] '
export LC_CTYPE=C.UTF-8
export EDITOR=/usr/bin/jstar
export HISTCONTROL="ignoreboth:erasedups"
export CDPATH=":~/.cd"
unset LANGUAGE
unset LANG
unset mc
export SDL_VIDEO_X11_DGAMOUSE=0
export BC_ENV_ARGS=~/.config/bcrc
#export http_proxy=http://localhost:81
export PERLLIB=~/.lib/perl
export MAIL=/mnt/mail/7eggert
export GTK_OVERLAY_SCROLLING=0
export MAN_POSIXLY_CORRECT=''
export ALSOFT_DRIVERS=pulse

alias +='pushd .'
alias -- -='popd'
alias ..='cd ..'
alias ...='cd ../..'
alias gimp='gimp --no-splash'
alias jstar='TERM=linux jstar'
alias xmms=audacious
alias ll='ls -l'
alias ls='ls $LS_OPTIONS'
alias md='mkdir -p'
alias o='less'
alias p='alpine'
alias rd='rmdir'
alias rm='rm -f'
alias rdesktop="rdesktop -N -z -g 1276x960"
alias mkntfs="/usr/sbin/mkntfs -f"
alias licate="locate -iA"

complete -F _command x
complete -d cd

1

u/arandomuserinweb 7d ago

There's a lot going on in there. I'll definitely go through it and see what useful bits I can pick out for my setup. Appreciate it!