Unison Bash Completion

If you don't use unison to keep folders synchronized you really should, it's great. It's like a two way rsync program.
Problem is I end up synchronizing a bunchy of folders in different locations for different projects and I prefer to start unison at the command-line. What I want is bash completion for unison. It's not that difficult to setup.
I just created a file in /etc/bash_completion.d called "unison" and it looks like this:
local cur prev opts
opts=$(python -c 'import glob,os,os.path;x = glob.glob(os.path.expanduser("~/.unison/*.prf")); print " ".join([os.path.split(y)[-1][:-4] for y in x])')

COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
complete -F _unison unison-gtk
The python part is all one line and it goes to my ~/.unison folder, lists all the *.prf files and then just gets the base names. I suppose most people would use awk, but my awk is a little rusty.


Popular posts from this blog

Shortest Sudoku solver in Python

Seven Segment Display in Inkscape

wny am I happy about the death of some people?