readme.org
#+TITLE: My main dotfiles
#+AUTHOR: James Richardson
#+EMAIL: james@jamestechnotes.com
#+SETUPFILE: setup
* My main dot files
As I have described [[file:~/readme.org::*fixups]], these are my main
dotfiles.
** .gitignore
Let's first handle =.gitignore=. The normal =.#*= and =\#*#= are the
to exclude emacs save files. The =known= file is there, as this file
is generated to [[*dircombine][dircombine]] to track symlinks. =fixups= manages
=.offlineimap= and =.gitconfig= so we keep them out of VCS. Adding
setup and nav to keep =git status= from website complaining.
#+name: gitignore
#+begin_listing
#+BEGIN_SRC sh :tangle .gitignore :padline no :comments noweb :noweb yes
known
.offlineimaprc
.gitconfig
\#*#
.#*
,*~
setup
nav
readme.html
#+END_SRC
#+end_listing
** fixups
This is run after a git checkout. The idea is to abstract out the
differences in hosts, but still have work out right. My
=$HOME/.ssh/authorized_keys=, for instance, will have different keys
on each host, but yet each host needs to have the file named the
same. The trick is being able to set this up where it can be managed
via VCS. If I have the host name in the file we can arrange to have it
symlinked into the appropriate place. We also need to handle the case
where we only wish to have a file present on certain hosts and not
every where. I typically only have a =~/.forward= present on a some
hosts. The =hostspecific= function takes care of the particulars. It
does this by making sure the file is a symlink. If it is not, it is
deleted. It then looks for =filename.$(hostname)=, if found creates a
symlink. It defaults to symlinking =filename.general= if present,
otherwise nothing is done. Obviously, if I ever run into a box named
general, this is broken.
#+begin_listing
#+name: hostspecific
#+BEGIN_SRC sh
hostspecific ()
{
if [ -e "${1}" -a ! -h "${1}" ]; then
rm "${1}"
fi
if [ -e "${1}.$(hostname)" ]; then
ln -sf "$(basename ${1}).$(hostname)" "${1}"
elif [ -e "${1}.general" ]; then
ln -sf "$(basename ${1}).general" "${1}"
fi
}
#+END_SRC
#+end_listing
Now we just have to fixup the appropriate files.
#+name: fixups
#+begin_listing
#+BEGIN_SRC sh
# Can't just assume home in the current directory.
cd
# [[file:~/.etc/readme.org::*fixups][hostspecific]]
hostspecific ()
{
if [ -e "${1}" -a ! -h "${1}" ]; then
rm "${1}"
fi
if [ -e "${1}.$(hostname)" ]; then
ln -sf "$(basename ${1}).$(hostname)" "${1}"
elif [ -e "${1}.general" ]; then
ln -sf "$(basename ${1}).general" "${1}"
fi
}
# hostspecific ends here
if ! [ -d .ssh ]; then
mkdir .ssh
fi
chmod 755 .ssh
hostspecific .ssh/authorized_keys
if [ -e .ssh/authorized_keys ]; then
chmod 600 .ssh/authorized_keys
fi
hostspecific .etc/.offlineimaprc
# need to have proper email
hostspecific .etc/.gitconfig
hostspecific .etc/.forward
#+END_SRC
#+end_listing
** .bashrc
This is my =.bashrc=
#+begin_listing
#+name: bashrc
#+BEGIN_SRC sh
. $HOME/.environment
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# Turn off posix mode if it somehow got turned on.
set +o posix
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# Enable the recursive wildcard **
shopt -s globstar 2>/dev/null
# Append history rather than replacing it
shopt -s histappend
# Do not complete an empty command (listing every program in $PATH)
shopt -s no_empty_cmd_completion
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
HISTSIZE=100000
unset HISTFILESIZE
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto -v'
else
alias ls='ls -v'
fi
# For use when piping into something like less that can handle color
alias cgrep='grep --color=always'
# Make Control-v paste, if in X and if xsel available
if [ -n "$DISPLAY" ] && [ -x /usr/bin/xsel ] ; then
# Work around a bash bug: \C-@ does not work in a key binding
bind '"\C-x\C-m": set-mark'
# The '#' characters ensure that kill commands have text to work on; if
# not, this binding would malfunction at the start or end of a line.
bind 'Control-v: "#\C-b\C-k#\C-x\C-?\"$(xsel -b -o)\"\e\C-e\C-x\C-m\C-a\C-y\C-?\C-e\C-y\ey\C-x\C-x\C-d"'
fi
# handle bash completion before setting PS1 so we can do cool things
# like add git branch to prompt....
if [ -z "$BASH_COMPLETION" ] && [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# determine if we have git completion
if [ -n "$(typeset -F __git_ps1)" ] ; then
have_git_completion=true
fi
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# Only show username and hostname if remote or unusual
if [ -n "$SSH_CONNECTION" ] || [ "$(id -un)" != "james" ] ; then
prompt_remote=true
fi
PS1='$(e="$?";[ "$e" -ne 0 ] && echo -n "\[\e[01;31m\]($e) ")${debian_chroot:+\[\e[01;37m\]($debian_chroot) }${prompt_remote:+\[\e[01;32m\]\u@\h\[\e[00m\]:}\[\e[01;34m\]\w${have_git_completion:+$(__git_ps1 " (%s)")}\[\e[00m\] \$ '
# Set title as appropriate for terminal
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${prompt_remote:+\u@\h: }\w\a\]$PS1"
;;
screen)
PS1="\[\ek${prompt_remote:+\u@\h: }\w\e"'\\'"\]$PS1"
;;
esac
#
# 4) Consider changing your PS1 to also show the current branch:
# PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
#
# The argument to __git_ps1 will be displayed only if you
# are currently in a git repository. The %s token will be
# the name of the current branch.
#+END_SRC
#+end_listing
** .devscripts
#+begin_listing
#+name: devscripts
#+BEGIN_SRC sh
DEBCHANGE_RELEASE_HEURISTIC=changelog
DEBCOMMIT_SIGN_TAGS=yes
DEBSIGN_KEYID=
DEBSIGN_SIGNLIKE=gpg
DEBSIGN_MAINT=james@jamestechnotes.com
DEBCHANGE_AUTO_NMU=no
#+END_SRC
#+end_listing
** .environment
#+begin_listing
#+name: environment
#+BEGIN_SRC sh
# Global environment file. Sources at shell start and X start
# Keep it simple and POSIX
# $HOME/.local/bin if exists
[ -s $HOME/.local/bin ] && PATH=$HOME/.local/bin:$PATH
PATH=$HOME/bin:$PATH
export PATH
unset LANG
# locale -a lists it differently than how it needs to be set..
if locale -a 2>/dev/null | grep -iq ^en_US.utf8\$; then
LANG=en_US.UTF-8
elif locale -a 2>/dev/null | grep -iq ^en_US\$; then
LANG=en_US
fi
export LANG
# No matter my LANG, I want sane unix-style sorting.
LC_COLLATE=C
export LC_COLLATE
# And good old ls -l dates
export LC_TIME
CVS_RSH=ssh
export CVS_RSH
# Select and editor.
if type emacs >/dev/null 2>&1; then
EDITOR="emacsclient -a \"\""
elif type vim >/dev/null 2>&1; then
EDITOR=vim
else
EDITOR=vi
fi
export EDITOR
VISUAL=$EDITOR
export VISUAL
if [ -n "$TERM" ]; then
BROWSER=lynx
export BROWSER
fi
#set up less.
LESS="-FMXI"
export LESS
type less >/dev/null 2>&1
if [ $? -eq 0 ]; then
PAGER=less
else
PAGER=more
fi
export PAGER
type lesspipe >/dev/null 2>&1
if [ $? -eq 0 ]; then
eval `lesspipe`
fi
# Set COLORTERM for slang programs if this is a color terminal
if [ "$TERM" = "xterm" -o "$TERM" = "linux" ]; then
export COLORTERM=y
fi
# Random environment settings.
IRCSERVER=
export IRCSERVER
DEBEMAIL=james@jamestechnotes.com
export DEBEMAIL
IRCNAME=jamesr
export IRCNAME
EMAIL='james@jamestechnotes.com'
# I use a different email at work, which is also the only time
# I use AIX. I guess I also need to set my email appropriately
# on the work workstation.
if [ "$(uname)" = "AIX" -o "$(hostname)" = "weasel" ]; then
EMAIL='james.richardson@lowes.com'
fi
export EMAIL
NAME='James Richardson'
export NAME
DEBFULLNAME="$NAME"
export DEBFULLNAME
GIT_AUTHOR_NAME="$NAME"
export GIT_AUTHOR_NAME
GIT_AUTHOR_EMAIL=$EMAIL
export GIT_AUTHOR_EMAIL
GIT_COMMITTER_NAME="$NAME"
export GIT_COMMITTER_NAME
GIT_COMMITTER_EMAIL=$EMAIL
export GIT_COMMITTER_EMAIL
# use $HOME/tmp when possible, out of general paranoia.
# So many programs have /tmp symlink races...
TMPDIR=$HOME/tmp
export TMPDIR
TMP=$HOME/tmp
export TMP
TEMP=$HOME/tmp
export TEMP
MAIL=$HOME/Maildir
export MAIL
# Clean vcs dirs when building packages.
DH_ALWAYS_EXCLUDE=CVS:.svn:.git
export DH_ALWAYS_EXCLUDE
# Use my own timezone EST
TZ=EST5EDT
export TZ
#setup rvm
[ -s "$HOME/.rvm/scripts/rvm" ] && . "$HOME/.rvm/scripts/rvm"
PYTHONPATH=$HOME/.python
export PYTHONPATH
INFOPATH=~/src/org-mode/doc:${INFOPATH}
export INFOPATH
#+END_SRC
#+end_listing
** .gitconfig
I have the common bits. Add default = simple to push.
#+begin_listing
#+nane: gitconfig-common
#+BEGIN_SRC sh
[color]
ui = true
[core]
pager = less -FMRX
[push]
default = simple
#+END_SRC
#+end_listing
Then I setup a block to tangle a generic file
#+begin_listing
#+name: gitconfig-generic
#+begin_src sh :tangle .gitconfig.generic :comments noweb :noweb yes :padline no
[user]
name = James Richardson
email = james@jamestechnotes.com
<<gitconfig-common>>
#+end_src
#+end_listing
and a block for weasel.
#+begin_listing
#+name: gitconfig-generic
#+begin_src sh :tangle .gitconfig.weasel :comments noweb :noweb yes :padline no
[user]
name = James Richardson
email = james.richardson@lowes.com
<<gitconfig-common>>
#+end_src
#+end_listing