1 #+TITLE: My main dotfiles
2 #+AUTHOR: James Richardson
3 #+EMAIL: james@jamestechnotes.com
8 As I have described [[file:~/readme.org::*fixups]], these are my main
12 Let's first handle =.gitignore=. The normal =.#*= and =\#*#= are the
13 to exclude emacs save files. The =known= file is there, as this file
14 is generated to [[*dircombine][dircombine]] to track symlinks. =fixups= manages
15 =.offlineimap= and =.gitconfig= so we keep them out of VCS. Adding
16 setup and nav to keep =git status= from website complaining.
20 #+BEGIN_SRC sh :tangle .gitignore :padline no :comments noweb :noweb yes
33 This is run after a git checkout. The idea is to abstract out the
34 differences in hosts, but still have work out right. My
35 =$HOME/.ssh/authorized_keys=, for instance, will have different keys
36 on each host, but yet each host needs to have the file named the
37 same. The trick is being able to set this up where it can be managed
38 via VCS. If I have the host name in the file we can arrange to have it
39 symlinked into the appropriate place. We also need to handle the case
40 where we only wish to have a file present on certain hosts and not
41 every where. I typically only have a =~/.forward= present on a some
42 hosts. The =hostspecific= function takes care of the particulars. It
43 does this by making sure the file is a symlink. If it is not, it is
44 deleted. It then looks for =filename.$(hostname)=, if found creates a
45 symlink. It defaults to symlinking =filename.general= if present,
46 otherwise nothing is done. Obviously, if I ever run into a box named
47 general, this is broken.
54 if [ -e "${1}" -a ! -h "${1}" ]; then
57 if [ -e "${1}.$(hostname)" ]; then
58 ln -sf "$(basename ${1}).$(hostname)" "${1}"
59 elif [ -e "${1}.general" ]; then
60 ln -sf "$(basename ${1}).general" "${1}"
66 Now we just have to fixup the appropriate files.
70 # Can't just assume home in the current directory.
73 # [[file:~/.etc/readme.org::*fixups][hostspecific]]
76 if [ -e "${1}" -a ! -h "${1}" ]; then
79 if [ -e "${1}.$(hostname)" ]; then
80 ln -sf "$(basename ${1}).$(hostname)" "${1}"
81 elif [ -e "${1}.general" ]; then
82 ln -sf "$(basename ${1}).general" "${1}"
85 # hostspecific ends here
87 if ! [ -d .ssh ]; then
92 hostspecific .ssh/authorized_keys
94 if [ -e .ssh/authorized_keys ]; then
95 chmod 600 .ssh/authorized_keys
98 hostspecific .etc/.offlineimaprc
100 # need to have proper email
101 hostspecific .etc/.gitconfig
103 hostspecific .etc/.forward
114 # If not running interactively, don't do anything
115 [ -z "$PS1" ] && return
117 # Turn off posix mode if it somehow got turned on.
120 # check the window size after each command and, if necessary,
121 # update the values of LINES and COLUMNS.
122 shopt -s checkwinsize
124 # Enable the recursive wildcard **
125 shopt -s globstar 2>/dev/null
127 # Append history rather than replacing it
130 # Do not complete an empty command (listing every program in $PATH)
131 shopt -s no_empty_cmd_completion
133 # make less more friendly for non-text input files, see lesspipe(1)
134 [ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
139 # enable color support of ls and also add handy aliases
140 if [ -x /usr/bin/dircolors ]; then
141 eval "`dircolors -b`"
142 alias ls='ls --color=auto -v'
147 # For use when piping into something like less that can handle color
148 alias cgrep='grep --color=always'
150 # Make Control-v paste, if in X and if xsel available
151 if [ -n "$DISPLAY" ] && [ -x /usr/bin/xsel ] ; then
152 # Work around a bash bug: \C-@ does not work in a key binding
153 bind '"\C-x\C-m": set-mark'
154 # The '#' characters ensure that kill commands have text to work on; if
155 # not, this binding would malfunction at the start or end of a line.
156 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"'
159 # handle bash completion before setting PS1 so we can do cool things
160 # like add git branch to prompt....
162 if [ -z "$BASH_COMPLETION" ] && [ -f /etc/bash_completion ]; then
163 . /etc/bash_completion
166 # determine if we have git completion
167 if [ -n "$(typeset -F __git_ps1)" ] ; then
168 have_git_completion=true
171 # set variable identifying the chroot you work in (used in the prompt below)
172 if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
173 debian_chroot=$(cat /etc/debian_chroot)
176 # Only show username and hostname if remote or unusual
177 if [ -n "$SSH_CONNECTION" ] || [ "$(id -un)" != "james" ] ; then
181 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\] \$ '
183 # Set title as appropriate for terminal
186 PS1="\[\e]0;${prompt_remote:+\u@\h: }\w\a\]$PS1"
189 PS1="\[\ek${prompt_remote:+\u@\h: }\w\e"'\\'"\]$PS1"
197 # 4) Consider changing your PS1 to also show the current branch:
198 # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
200 # The argument to __git_ps1 will be displayed only if you
201 # are currently in a git repository. The %s token will be
202 # the name of the current branch.
209 DEBCHANGE_RELEASE_HEURISTIC=changelog
210 DEBCOMMIT_SIGN_TAGS=yes
213 DEBSIGN_MAINT=james@jamestechnotes.com
214 DEBCHANGE_AUTO_NMU=no
221 # Global environment file. Sources at shell start and X start
222 # Keep it simple and POSIX
224 # $HOME/.local/bin if exists
225 [ -s $HOME/.local/bin ] && PATH=$HOME/.local/bin:$PATH
231 # locale -a lists it differently than how it needs to be set..
232 if locale -a 2>/dev/null | grep -iq ^en_US.utf8\$; then
234 elif locale -a 2>/dev/null | grep -iq ^en_US\$; then
240 # No matter my LANG, I want sane unix-style sorting.
243 # And good old ls -l dates
250 if type emacs >/dev/null 2>&1; then
251 EDITOR="emacsclient -a \"\""
252 elif type vim >/dev/null 2>&1; then
261 if [ -n "$TERM" ]; then
269 type less >/dev/null 2>&1
270 if [ $? -eq 0 ]; then
277 type lesspipe >/dev/null 2>&1
278 if [ $? -eq 0 ]; then
282 # Set COLORTERM for slang programs if this is a color terminal
283 if [ "$TERM" = "xterm" -o "$TERM" = "linux" ]; then
287 # Random environment settings.
290 DEBEMAIL=james@jamestechnotes.com
294 EMAIL='james@jamestechnotes.com'
295 # I use a different email at work, which is also the only time
296 # I use AIX. I guess I also need to set my email appropriately
297 # on the work workstation.
298 if [ "$(uname)" = "AIX" -o "$(hostname)" = "weasel" ]; then
299 EMAIL='james.richardson@lowes.com'
302 NAME='James Richardson'
306 GIT_AUTHOR_NAME="$NAME"
307 export GIT_AUTHOR_NAME
308 GIT_AUTHOR_EMAIL=$EMAIL
309 export GIT_AUTHOR_EMAIL
310 GIT_COMMITTER_NAME="$NAME"
311 export GIT_COMMITTER_NAME
312 GIT_COMMITTER_EMAIL=$EMAIL
313 export GIT_COMMITTER_EMAIL
315 # use $HOME/tmp when possible, out of general paranoia.
316 # So many programs have /tmp symlink races...
327 # Clean vcs dirs when building packages.
328 DH_ALWAYS_EXCLUDE=CVS:.svn:.git
329 export DH_ALWAYS_EXCLUDE
331 # Use my own timezone EST
336 [ -s "$HOME/.rvm/scripts/rvm" ] && . "$HOME/.rvm/scripts/rvm"
338 PYTHONPATH=$HOME/.python
341 INFOPATH=~/src/org-mode/doc:${INFOPATH}
347 I have the common bits. Add default = simple to push.
349 #+nane: gitconfig-common
360 Then I setup a block to tangle a generic file
362 #+name: gitconfig-generic
363 #+begin_src sh :tangle .gitconfig.generic :comments noweb :noweb yes :padline no
365 name = James Richardson
366 email = james@jamestechnotes.com
370 and a block for weasel.
372 #+name: gitconfig-generic
373 #+begin_src sh :tangle .gitconfig.weasel :comments noweb :noweb yes :padline no
375 name = James Richardson
376 email = james.richardson@lowes.com