Shells and oher configurations
System
Statically map useful IP addresses to hostnames in /etc/hosts:
#<ip-address> <hostname.domain.org> <hostname>
127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost ip6-localhost
Set locale in /etc/locale.conf:
LANG=en_US.UTF-8
LC_COLLATE=C
Define system-wide environment variables in /etc/profile:
# /etc/profile
appendpath () {
case ":$PATH:" in
*:"$1":*)
;;
*)
PATH="${PATH:+$PATH:}$1"
esac
}
# Set our default path (/usr/sbin:/sbin:/bin included for non-Void chroots)
appendpath '/usr/local/sbin'
appendpath '/usr/local/bin'
appendpath '/usr/bin'
appendpath '/usr/sbin'
appendpath '/sbin'
appendpath '/bin'
unset appendpath
export PATH
export XDG_CONFIG_HOME=$HOME/.config
export XDG_CACHE_HOME=$HOME/.cache
export XDG_DATA_HOME=$HOME/.local/share
export XDG_STATE_HOME=$HOME/.local/state
export XAUTHORITY=$HOME/.Xauthority
export XDG_RUNTIME_DIR=/tmp/$USER-runtime
mkdir -p $XDG_RUNTIME_DIR
chmod 0700 $XDG_RUNTIME_DIR
# Termcap is outdated, old, and crusty, kill it.
unset TERMCAP
# Man is much better than us at figuring this out
unset MANPATH
# Set default umask
umask 022
# climenu settings
export CM_IGNORE_WINDOW=\.\*KeePassXC\$
export _JAVA_AWT_WM_NONREPARENTING=1
export TERMCMD=urxvt
export EDITOR=vim
export QT_QPA_PLATFORMTHEME=qt5ct
# Load profiles from /etc/profile.d
if [ -d /etc/profile.d/ ]; then
for f in /etc/profile.d/*.sh; do
[ -r "$f" ] && . "$f"
done
unset f
fi
If you want to have consistent behaviour of interaction with command line (tab completition, history, cursor movement …) accross shells, interpreters and any tools using readline library, place your configuration into /etc/inputrc:
# Be 8 bit clean.
set input-meta on
set output-meta on
set bell-style none
"\e[A": history-search-backward
"\e[B": history-search-forward
set colored-stats on
set completion-ignore-case on
set show-all-if-ambiguous on
set show-all-if-unmodified on
set enable-bracketed-paste on
Setup reading bashrc from ~/.config in /etc/bash/bashrc.d/10-homeconfig.sh:
[ -e "$HOME/.config/bash/bashrc" ] && source "$HOME/.config/bash/bashrc"
Configure history in /etc/bash/bashrc.d/20-history.sh:
export HISTFILE="$HOME/.config/bash/bash_history"
export HISTSIZE=1000000
export SAVEHIST=1000000
export PROMPT_COMMAND='history -a'
export HISTCONTROL=ignoreboth:erasedups
USER
Upon login set some variables and ask wheather to start X, wayland or nothing, in ~/.profile:
export RANGER_LOAD_DEFAULT_RC=FALSE
export GNUPGHOME="$HOME/.config/gpg"
export QT_QPA_PLATFORMTHEME=qt5ct
export GDK_DPI_SCALE=1
export QT_FONT_DPI=96
export QT_AUTO_SCREEN_SCALE_FACTOR=0
export NPM_CONFIG_PREFIX="$HOME/dat/bin/npm-global"
export GEM_HOME="$HOME/dat/bin/gems"
export GOPATH="$HOME/dat/bin/go"
export PATH="$PATH:$GOPATH/bin:$GEM_HOME/bin:$HOME/dat/bin:$HOME/dat/bin/npm-global/bin"
if [[ -z $DISPLAY ]] && ! [[ -e /tmp/.X11-unix/X0 ]] && (( EUID )); then
while true; do
echo 'X?(x) W?(w)'
read
case $REPLY in
[Xx]) exec startx ;;
[Ww]) exec sway ;;
*) break ;;
esac
done
fi
Shell
File .config/aliases.sh contains aliases so that they can be sourced from rc files of different shells:
#!/bin/sh
alias ls='ls --color=auto'
alias la='ls -a'
alias ll='ls -l'
alias lal='ls -al'
alias bcl='bc -l'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias ff="find . -type f -name"
alias rm='rm -Iv --preserve-root'
alias mv='mv -iv'
alias cp='cp -iv'
alias ln='ln -iv'
alias lns='ln -ivs'
alias cal='cal -m'
alias psgrep='ps aux | grep -v grep | grep '
alias ptree='ps axjf'
alias pstree='pstree -ach'
alias lsdev='lsblk -a -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT'
alias ranger='ranger --choosedir=$HOME/rangerdir; LASTDIR=`\\cat $HOME/rangerdir`; cd "$LASTDIR"'
alias gitk='gitk --all'
hexdiff () {
diff -W140 -y <(xxd "$1") <(xxd "$2") | colordiff
}
~/.config/bashrc:
# .bashrc
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# Get the aliases and functions
[ -e $HOME/.config/aliases.sh ] && . $HOME/.config/aliases.sh
PS1='\[\e[0;31m\]${?}\n\[\e[0;37m\]\w \[\e[1;37m\]>\[\e[0m\] '
Bash requires that any non-printing escape sequences (like colors or cursor movement) in PS1 are wrapped with \[
and \]
.
ROOT
I like root to have red prompt.
/root/.config/bash/bashrc:
# .bashrc
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
PS1='\[\e[0;31m\]${?}\n\[\e[0;35m\]\w\n\[\e[1;31m\]# \[\e[0m\]'