This is my personal repository of dotfiles, including most of the settings that migrate well between machines. You can fork and use this directly, but it’s more likely you’ll want to read the files and find snippets relevant to your workflow.
$ git clone git://github.com/tejr/dotfiles.git ~/.dotfiles
$ cd ~/.dotfiles
$ git submodule init
$ make
$ make -n install
$ make install
For the default target, you’ll need bash(1)
, git(1)
, install(1)
,
make(1)
, m4(1)
, and tic(1)
. You’ll need to have a recent enough version
of Git to support submodules
for the Vim installation to work; it’s required for the plugin setup.
The installation Makefile
will overwrite things standing in the way of its
installed files without backing them up, so read the output of make -n install
before running make install
to make sure you aren’t going to lose
anything unexpected. If you’re still not sure, install it in a temporary
directory so you can explore:
$ tmpdir=$(mktemp -d)
$ make install HOME="$tmpdir"
$ env -i HOME="$tmpdir" TERM="$TERM" bash -l
The default target will install the core terminal-only files (cURL, Git, GnuPG,
Vim, and shell and terminal setup files). The remaining dotfiles can be
installed with the other targets. Take a look at the Makefile
to see what’s
available.
Configuration is included for:
- Abook — curses address book program
- Bash — GNU Bourne-Again Shell,
including a
~/.profile
configured to work with most Bourne-compatible shells - cURL — Command-line tool for transferring data with URL syntax
dircolors(1)
— Color GNUls(1)
output- Dunst — A lightweight X11 notification daemon
that works with
libnotify
- Git — Distributed version control system
- GnuPG — GNU Privacy Guard, for private communication and file encryption
- GTK+ — GIMP Toolkit, for graphical user interface elements
- i3 — Tiling window manager
- Mutt — Terminal mail user agent
mysql(1)
— Command-line MySQL client- Ncmpcpp — ncurses music player client
- Newsbeuter — Terminal RSS/Atom feed reader
psql(1)
— Command-line PostgreSQL client- Perl::Critic — static source code analysis engine for Perl
- Readline — GNU library for user input used by Bash, MySQL, and others
- Taskwarrior — Command-line task list manager
- tmux — Terminal multiplexer similar to GNU Screen
- rxvt-unicode — Fork of the rxvt terminal emulator with Unicode support
- Subversion — Apache Subversion, a version control system
- Vim — Vi IMproved, a text editor
- Wyrd — a
curses
calendar frontend for Remind - X11 — Windowing system with network transparency for Unix
- Zsh — Bourne-style shell designed for interactive use
Also included are a few scripts for ~/.local/bin
, and their man(1)
pages.
The configurations for Bash, GnuPG, Mutt, tmux, and Vim are the most expansive and most likely to be of interest. The i3 configuration is mostly changed to make window switching behave like Vim windows and tmux panes do, and there’s a fair few resources defined for rxvt-unicode. Otherwise, the rest of the configuration isn’t too distant from the defaults.
My .profile
and other files in sh
are written in Bourne/POSIX shell script,
so they should work in most sh(1)
implementations. Individual scripts called
by .profile
are saved in .profile.d
and iterated on login for ease of
management. All of these boil down to exporting variables appropriate to the
system and the software it has available.
My .bash_profile
calls .profile
and then runs subscripts in
.bash_profile.d
. It then runs .bashrc
, which only applies for interactive
shells; subscripts for that in turn are loaded from .bashrc.d
. The contents
of the two directories changes depending on the host, so only specific scripts
in it are versioned.
My interactive and scripting shell of choice is Bash; as a GNU/Linux admin who ends up installing Bash on *BSD machines anyway, I very rarely have to write Bourne-compatible scripts, so all of these files are replete with Bashisms.
As I occasionally have work on very old internal systems, my Bash is written to work with any version 2.05a or newer. This is why I use older syntax for certain things such as appending items to arrays:
array[${#array[@]}]=$item
Compare this to the much nicer syntax available since 3.1-alpha1, which actually works for arrays with sparse indexes, unlike the above syntax:
array+=("$item")
Where I do use features that are only available in versions of Bash newer than
2.05a, such as newer shopt
options or PROMPT_DIRTRIM
, they are only run
after testing BASH_VERSINFO
appropriately.
When I use any other Bourne-compatible shell, I’m generally happy to accept its defaults for interactive behavior.
My prompt looks something like this:
It expands based on context to include these elements in this order:
- Whether in a Git, Mercurial, or Subversion repository if applicable, and punctuation to show whether there are local modifications at a glance
- The number of running background jobs, if non-zero
- The exit status of the last command, if non-zero
You can set PROMPT_PREFIX
and/or PROMPT_SUFFIX
too, which do about what
you’d expect.
This is all managed within the prompt
function. There’s some mildly hacky
logic on tput
codes included such that it should work correctly for most
common terminals using both termcap(5)
and terminfo(5)
, including *BSD
systems. It’s also designed to degrade gracefully for eight-color and no-color
terminals.
I find the bash-completion
package a bit too heavy for my tastes, and turn it
off using a stub file installed in .config/bash_completion
. The majority of
the time I just want to complete paths anyway, and this makes for a quicker
startup without a lot of junk functions in my Bash namespace.
I do make some exceptions with completions defined in .bashrc.d
files for
things I really do get tired of typing repeatedly:
- Builtins, commands, help topics, shell options, and variables
ftp(1)
hostnames from~/.netrc
git(1)
branch namesgpg(1)
long optionsmake(1)
targets read from aMakefile
man(1)
page titlesmysql(1)
databases from~/.mysql/*.cnf
pass(1)
entriesssh(1)
hostnames from~/.ssh/config
There are a few other little tricks in bash/bashrc.d
, including:
apf
— Prepend arguments to a command with ones read from a filebd
— Change into a named ancestor of the current directoryca
— Count given argumentscf
— Count files in a given directoryfnl
— Run a command and save its output and error into temporary fileshgrep
—HISTFILE
searchkeep
— Permanently store ad-hoc shell functions and variablesmkcd
— Create a directory and change into itmkcp
— Create a directory and copy arguments into itmkmv
— Create a directory and move arguments into itpa
— Print given arguments, one per linepath
— Manage the contents ofPATH
convenientlypaz
— Print given arguments separated by NULL charspd
— Change to the argument’s parent directoryreadz
— Alias forread -d '' -r
scr
— Create a temporary directory and change into itsd
— Switch to a sibling directorysprunge
— Pastebin frontend tool I pilfered from#bash
on Freenodeud
— Change into an indexed ancestor of a directory
I also wrap a few command calls with functions to stop me from doing silly
things that the commands themselves don’t catch. My favourite is the one that
stops me from calling scp(1)
with no colon in either argument. I also do
things like give default arguments to pwgen(1)
.
The configuration for GnuPG is intended to follow RiseUp’s OpenPGP best
practices.
The configuration file is rebuilt using m4(1)
and make(1)
because it
requires hard-coding a path to the SKS keyserver certificate authority, and
neither tilde nor $HOME
expansion works for this.
My mail is kept in individual Maildirs under ~/Mail
, with inbox
being where
most unfiltered mail is sent. I use
Getmail,
Procmail, and
MSMTP; the configurations for these are not
included here. I make heavy use of GnuPG for email—everything is signed by
default, and I encrypt whenever I have a public key available for the
recipient. The GnuPG interfacing is done with
GPGme, rather than defining
commands for each crypto operation. I wrote an article about this
setup if it sounds appealing.
You’ll need Abook installed if you want to use
the query_command
I have defined, and msmtp
for the sendmail
command.
A tiny script called clip
is included in ~/.urxvt/ext
to copy selections
into the X CLIPBOARD
buffer as well as PRIMARY
. This is purely preference
as I find it pretty maddening otherwise, particularly when dealing with URLs
from IRC.
The included .Xresources
file assumes that urxvt
can use 256 colors and
Perl extensions. If you’re missing functionality, try changing
perl-ext-common
to default
.
My choice of font is Ubuntu Mono, but the file should allow falling back to the more common Deja Vu Sans Mono. I’ve found Terminus works well too, but bitmap fonts are not really my cup of tea. The Lohit Kannada font bit is purely to make ಠ_ಠ work correctly. ( ͡° ͜ʖ ͡°) seems to work out of the box.
These are just generally vi-friendly settings, not much out of the ordinary. Note that the configuration presently uses a hard-coded 256-color colorscheme, and uses non-login shells, with an attempt to control the environment to stop shells thinking they have access to an X display—I’m forced to use PuTTY a lot at work, and I don’t like Xming very much.
The configuration for Bash includes a tmux
function designed to make attach
into the default command if no arguments are given and sessions do already
exist. The default command is normally new-session
.
The majority of the .vimrc
file is just setting options, with a few mappings.
I try not to deviate too much from the Vim defaults behaviour in terms of
interactive behavior and keybindings.
The configuration is extensively commented, mostly because I was reading through it one day and realised I’d forgotten what half of it did. Plugins are loaded using @tpope’s pathogen.vim.
- Three SSH-related scripts:
shoal(1)
— Print hostnames read from assh_config(5)
filescatter(1)
— Run command on multiple hosts read fromshoal(1)
and print outputshock(1)
— Run command on multiple hosts read fromshoal(1)
and print the hostname if the command returns zero
edda(1)
provides a means to runed(1)
over a set of files preserving any options, mostly useful for scripts. There’s--help
output and a manual page.han(1)
provides akeywordprg
for Vim's Bash script filetype that will look forhelp
topics. You could use it from the shell too. It also has a brief manual.sue(8)
execssudoedit(8)
as the owner of all the file arguments given, perhaps in cases where you may not necessarily haveroot
sudo(8)
privileges.vis(1)
edits executable script files inVISPATH
, defaulting to~/.local/bin
, for personal scripting snippets.
If you want to use the manuals, you may need to add ~/.local/share/man
to
your /etc/manpath
configuration, depending on your system.
You can test that both sets of shell scripts are syntactically correct with
make test-bash
, make test-sh
, or make test
for everything including the
scripts in bin
.
If you have ShellCheck and/or
Perl::Critic, there’s a lint
target for the shell
script files and Perl files respectively. The files don’t need to pass that
check to be installed.
I’d welcome patches or advice on fixing any of these problems.
- The
install-terminfo
target does not work correctly on NetBSD due to the different waytic(1)
works, which I don’t understand at all.
Public domain; see the included UNLICENSE
file. It’s just configuration, do
whatever you like with it if any of it’s useful to you. If you’re feeling
generous, you could always buy me a coffee next
time you’re in New Zealand.