Skip to content

Instantly share code, notes, and snippets.

@zachwhaley
Created April 1, 2014 15:41
Show Gist options
  • Save zachwhaley/9916754 to your computer and use it in GitHub Desktop.
Save zachwhaley/9916754 to your computer and use it in GitHub Desktop.
perforce bash completion
#!/bin/bash
function _p4()
{
local cmds='add annotate attribute branch branches change changes changelist changelists client clients copy
counter counters cstat delete depot depots describe diff diff2 dirs edit filelog files fix fixes flush fstat grep
group groups have help info integrate integrated interchanges istat job jobs key keys label labels labelsync list
lock logger login logout merge move open opened passwd populate print protect protects reconcile rename reopen
resolve resolved revert review reviews set shelve status sizes stream streams submit sync tag tickets unlock
unshelve update user users where workspace workspaces'
if [ ${COMP_CWORD} -eq 1 ]; then
COMPREPLY=( $(compgen -W '${cmds}' -- ${COMP_WORDS[1]}) )
elif [[ ${COMP_CWORD} -eq 2 && ${COMP_WORDS[1]} = 'help' ]]; then
COMPREPLY=( $(compgen -W '${cmds}' -- ${COMP_WORDS[2]}) )
else
COMPREPLY=( $(compgen -f ${COMP_WORDS[${COMP_CWORD}]}) )
fi
}
complete -o filenames -o bashdefault -F _p4 p4
@zachwhaley
Copy link
Author

zachwhaley commented Mar 14, 2016

I moved this to an actual repo https://github.com/zachwhaley/p4-completion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment