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:
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:
_unison()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.
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
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
Comments