jasonwryan.com

Miscellaneous ephemera…

Using Mercurial to Share Dotfiles

I posted a couple of weeks back about using dropbox to share dotfiles and while I am pleased with how well that works, I had always intended to see how well a version control system would handle that (relatively trivial) chore.

I chose Mercurial only because it is the system used by the suckless community and, as their philosophy and the products they produce are of such exceptional quality, no further investigation seemed necessary.

Installing mercurial, on both my Arch machines and the Ubuntu box was simple enough:

1
# pacman -S mercurial

Then, rather than use my /home directory as the local repo (which for some reason—probably completely irrational—seemed somewhat risky), I opted to create the repository in a separate directory in my home folder and link to the relevant files.

I signed up for a free account at bitbucket and created a repository called “dotfiles.”

The it was just a matter of cloning the new repository to my local machine:

1
hg clone https://jasonwryan@bitbucket.org/jasonwryan/dotfiles/

and then entering the newly created directory and linking to the files that I wanted to share:

1
2
cd dotfiles/ ln /home/jason/.Xdefaults ln /home/jason/.apvlvrc

Note: I initially tried symlinking, but Mercurial didn’t like that at all, hence the hard links…

Then it was just a matter of telling Mercurial that the requisite files are in the folder:

1
hg add

Commit the changes:

1
hg ci

…and then push the changes to the bitbucket repository:

1
hg push

This was certainly a lot quicker to setup than the Dropbox method but, for all that I am using it for, it seems a little like overkill. I’ll chalk it up as a good way for me to get my head around vcs more than anything else…

The Mercurial Book

For more information on Mercurial, I highly recommend Bryan O'Sullivan’s excellent Mercurial: The Definitive Guide.

Update

Post edited to reflect that fact that I now run two repos, one for the workstation (as described here), and a second one for my EeePC – which I did successfully create in /home without any apocalyptic consequences.

Using Dropbox to Share Dotfiles

I regularly back up all my dotfiles to Dropbox as a matter of course. I had intended, at some point, to set up a Git repo to automate the process and to make it easier to share these files with others.

However, best intentions etc., in the end it was far easier to simply extend what I was already doing using Dropbox.

First, I created a directory in my Dropbox/Public that would contain the dotfiles I wanted to share:

1
$ mkdir Dropbox/Public/Configs

Then it was just a matter of creating links to the files I wanted to host there:

1
2
3
$ cd Dropbox/Public/Configs
$ ln -s ../../path/to/dotfile

The next step was to create a simple HTML page (and a stylesheet to make it look presentable) and drop them into the same directory.

Caveat

Dropbox has the very handy feature of retaining versions of all the files you upload. Unfortunately, in this case, that means that the symlinks will always point to the file that you originally set them at — irrespective of any updates you overwrite them with.

So, if you change any of the files significantly, you will need to recreate the symlink…

Update

It seems that the symlink system does work: Dropbox will respect the latest version. YMMV.

tmux - terminal multiplexer

Over the last couple of days I have been familiarising myself with tmux. As it says on the homepage,

tmux is a terminal multiplexer: it enables a number of terminals (or windows), each running a separate program, to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.

I was attracted to tmux after seeing a number of enthusiastic postings on the Arch forums, and by the promise of better management of multiple terminals in a single dwm tag

It’s available in the community repo, so:

1
pacman -S tmux

Then it is just a matter of configuring it to suit your style of working, keyboard bindings etc. Helpfully, it comes with some example config files to start you off. These can be found at /usr/share/tmux/*.conf. I borrowed heavily from Thayer Williams' for mine:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# set prefix key to ctrl+t
unbind C-b
set -g prefix C-t

# more intuitive keybindings for splitting
unbind %
bind h split-window -h
unbind '"'
bind v split-window -v

# set vi keys
unbind [
bind Escape copy-mode
setw -g mode-keys vi

# send the prefix to client inside window (ala nested sessions)
bind-key a send-prefix

# toggle last window like screen
bind-key C-b last-window

# confirm before killing a window or the server
bind-key k confirm kill-window
bind-key K confirm kill-server

# toggle statusbar
bind-key b set-option status

# ctrl+left/right cycles thru windows
bind-key -n C-right next
bind-key -n C-left prev

# open a man page in new window
bind / command-prompt "split-window 'exec man %%'"

# quick view of processes
bind '~' split-window "exec htop"

# scrollback buffer n lines
set -g history-limit 5000

# on-screen time for display-panes in ms
set -g display-panes-time 2000

# start window indexing at one instead of zero
set -g base-index 1

# enable wm window titles
set -g set-titles on

# wm window title string (uses statusbar variables)
set -g set-titles-string "tmux:#I #W"

# session initialization
new -s TTYtter ttytter
neww -t 2
neww -d -t 3
neww -d -t 5
selectw -t 1

#### statusbar ####
set -g status-interval 1
set -g status-justify centre # center align window list
set -g status-left '#[fg=green] #H #[default]'
set -g status-right '#[fg=blue,bright]Up#(uptime | cut -f 4-5 -d " " | cut -f 1 -d ",") 
#[default]:: #[fg=cyan]#(cut -d " " -f 1-4 /proc/loadavg) '

# default statusbar colors
set -g status-fg white
set -g status-bg default
set -g status-attr bright

# default window title colors
set-window-option -g window-status-fg white
set-window-option -g window-status-bg default
set-window-option -g window-status-attr dim

# active window title colors
set-window-option -g window-status-current-fg white
set-window-option -g window-status-current-bg default
set-window-option -g window-status-current-attr bright

# command/message line colors
set -g message-fg white
set -g message-bg black
set -g message-attr bright

Copy this file to ~/.tmux.conf. The final result:

Archlinux:  tmux running in dwm

Updated 16/11/10

For a current version of my .tmux.conf, check my mercurial repository.