Typing in anything can be a tedious process, and is best to be avoided. Indeed, many physicians believe that keyboards are bad for your hands. However, we all know that doing somethings besides typing is not really an option. Instead, we use completion.
The completion script is included in svk 1.05 and later. To use it, put svk-completion.pl somewhere on your path, then tell bash to use it to generate completions by running "complete -C PATH-TO-svk-completion.pl -o default svk".
In other words:
- cp contrib/svk-completion.pl /usr/local/bin
- chmod 755 /usr/local/bin/svk-completion.pl
- complete -C /usr/local/bin/svk-completion.pl -o default svk
After running that last command completion will work in your current shell. If you want it to work in every shell you open, you need to add the command to your startup files. The exact file depends on your OS and shell, often it's "~/.bashrc".
Older discussion follows:
Here is a small bash script which provides svk path completion. Since I don't need to complete parts of commands such as -ci and such, I didn't bother including that. Feel free to add that if you like. Without further ado:
_svk_path()
{
cur=${COMP_WORDS[COMP_CWORD]}
if [[ $cur == //*/* ]]; then
tail=`echo $cur | sed -r 's|^.*/([^/]*)$|\1|'`
head=`echo $cur | sed -r 's|^(.*)(/[^/]*)$|\1|'`
elif [[ $cur == //* ]]; then
tail=`echo $cur | sed 's|^//||'`
head="//"
else
return 0
fi
if [ $head == '//' ]; then
insert='//'
else
insert="$head/"
fi
words=`svk ls $head | sed "s|^|$insert|" | tr '\n' ' '`
COMPREPLY=( $( compgen -W "$words" -- $cur ) )
return 0
}
complete -F _svk_path -o default -o nospace svk
You can also download [attachment] from this page, it's bash completion script that know everything about SVK commands, thier arguments and depotpaths. Use next steps to install it:
# download it and place it where all SVK users can access it > chmod +x /path/to/svk-bash-complete # add next line to bashrc file complete -C /path/to/svk-bash-complete -o default svk
Enjoy... --RuslanZakirov
[The newer attachment] adds a Shell::Complete::Zsh, which, combined with the following, allows the same basic completion to work in zsh.
It also fixes option completion, to work for command aliases. --MatthewDraper
Save this into /usr/share/zsh/site-functions/_svk:
#compdef svk
_svk () {
if [ $CURRENT -gt 2 ]; then
_alternative ':local files:_files' ':svk:_svk_call'
else
_svk_call
fi
}
_svk_call () {
export BUFFER CURSOR SHELL=zsh
compadd -- ${(f)"${(ps:\r:)$(perl /path/to/svk-complete.pl svk $words[$CURRENT] '' | sed 's/ *$//')}"}
}
_svk "$@"
Obviously, you'll need to adapt the path as appropriate. If your SVN::Mirror and SVK lib paths are not in your standard perl include path, you can add appropriate -I arguments to the perl invocation.
[attachemnt] combines two previouse solution so it works with bash and zsh, but also fixes some compatibility bugs. This version should work not only with svk trunk, but also with svk 1.04 and earlier. --RuslanZakirov
Last time I checked this wiki, the ZSH completion support was quite poor ; that's why I wrote my own one (git clone git://gaffer.ptitcanardnoir.org/zsh-svk.git), which brings a pretty complete SVK completion for ZSH (including options et al.) ; it uses svk-complete.pl to complete the depotpaths, but does everything else without any Perl script, which means it is really, really faster.