Here's my setup; it is very quirky:
I use bash
. I don't modify any of the system-installed shell init files; I just suck them in and override what I want. This way I can use pretty much the same bash
rc
files on all my OSes (Linux, FreeBSD, NetBSD). Also makes re-installing easier: Install the OS, then untar my overlay on top of the base install.
Terminal is xterm
, and each xterm
runs a login shell.
Window manager is evilwm
, and every window is full-screened. I use virtual desktops and stacking a lot.
The first 4 virtual desktops run xterm
. They are dedicated for specific "tasks".
Desktop 1 has xterm
running top -s2
--for system status and date.
Desktop 2 is for programming--main xterm
and editor, etc. I flip back and forth using Alt-TAB.
Desktop 3 is for documentation--man-pages and stuff.
Desktop 4 has an xterm for misc. things--running a music/video player, mostly.
Desktop 8 has the browser (Firefox).
Additonal xterms are temporaries (mostly created for testing stuff out) and so don't save any command-line history. I store a lot of shell history and don't want it cluttered with useless stuff. (So I "compact" it; see below.)
The idea is to have a pure console experience with conveniences like nice fonts and proper mouse support.
The rc
files themselves won't be of much use for most people. Regard them as curiosities. Files are presented in calling sequence order. From the top:
~/.bash_profile
# ~/.bash_profile
test -r ~/.profile && . ~/.profile
test -r ~/.bashrc && . ~/.bashrc
c=$(who | awk -v U="$(id -n -u)" '$1 == U { c++ } END { print c }')
test $c -eq 1 || cd ~/work
test $c -le 4 && { fortune -a; echo; } # early birds get cookie
~/.bashrc
# ~/.bashrc
umask 077
shopt -u lithist # single-line hist. ents. for `nuniq.sh'
# don't save history on pseudo-ttys nos. > 3
ntty=$(expr "$(tty)" : '/dev/pts/\([0-9][0-9]*\)$')
if [ -n "$ntty" ] && [ "$ntty" -gt 3 ]
then trap 'history -c' EXIT HUP
fi
rf()
{
for f
do if [ -r "$f" ]
then . "$f"
fi
done
unset f
}
rf ~/.shrc ~/.bash_aliases
unset rf
export PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R7/bin:/usr/pkg/bin:/usr/pkg/sbin:/usr/games:/usr/local/bin:/usr/local/sbin
export PS1='\[\e[1;36m\]\l\[\e[0m\] \[\e[1;35m\]\w\[\e[0m\] '
export HISTCONTROL=erasedups:ignorespace
export HISTSIZE=100000
export HISTFILESIZE=1000000
export BLOCKSIZE=1k
export LESS=-cFX LESSHISTFILE=/dev/null # make less(1) more like more(1)
export PAGER="less -s"
export XDG_CONFIG_HOME=$HOME/.config
export XDG_RUNTIME_DIR=$HOME/.local
test -d $XDG_RUNTIME_DIR || mkdir $XDG_RUNTIME_DIR
export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"
export CVS_RSH="ssh"
export CC=gcc
export CFLAGS="-Wall -Wconversion -Wextra -O2 -flto -fpie -fstack-protector-all -fstack-protector-strong -march=native -pipe"
export LDFLAGS="-pie -s"
export CXX="g++" CXXFLAGS="$CFLAGS"
export LEX=lex YACC=yacc
~/.bash_aliases
# ~/.bash_aliases
alias c=clear
alias cp='cp -ip'
alias mv='mv -i'
alias rm='rm -i'
alias ls='ls -p'
alias p='ps -aux'
alias s=sync
alias vi='vi -R'
alias lynx='/opt/lynx/bin/lynx -use_mouse'
~/.bash_logout
# ~/.bash_logout
# clear console on logout
if [ "$SHLVL" = 1 ]
then /usr/bin/clear
fi
# compact shell history file on final logout
c=$(who | awk -v U=$(id -n -u) '$1 == U { c++ } END { print c }')
if ((c <= 1))
then history -a
buniq.sh
rm -rf ~/.local/
fi
sync
These last two files, however, should be of use for other folk too:
~/bin/buniq.sh
#!/bin/sh
#
# buniq.sh: safely run `nuniq.sh' on ~/.bash_history
set -eu
ORIG=$HOME/.bash_history
TMP=${ORIG}.tmp.$$
sed -Ee 's/[[:blank:]]+$//; /^$/d' "$ORIG" | nuniq.sh > "$TMP"
touch -r "$ORIG" "$TMP"
mv -f "$TMP" "$ORIG"
~/bin/nuniq.sh
#!/bin/sh
#
# nuniq.sh: Remove duplicate lines, leaving only the last one.
# (based on histsort.awk from "GAWK: Effective AWK Programming")
exec awk '
{
lines[NR] = $0
if ($0 in array)
delete lines[array[$0]]
array[$0] = NR
}
END {
for (i = 1; i <= NR; i++)
if (i in lines)
print lines[i]
}' "$@"