From: Blaisorblade <blaisorblade@yahoo.it>
To: Catalin Marinas <catalin.marinas@gmail.com>, git@vger.kernel.org
Subject: StGit command completions - and Git ones?
Date: Sun, 2 Oct 2005 13:03:44 +0200 [thread overview]
Message-ID: <200510021303.44960.blaisorblade@yahoo.it> (raw)
[-- Attachment #1: Type: text/plain, Size: 852 bytes --]
I noticed in your TODO you talk about adding command line completions. I've
been doing it for my needs, and the thing is still very incomplete, even if
it's not a "XXX hack hack hack", and I wanted to send this first draft.
Note: I've not tried to add any completion which isn't StGit specific:
a) I didn't need them
b) they should be implemented for git and cogito first
c) not everything is clear. For instance, I think that SHA1 completion is
pretty useless (I never type a SHA1), while only branch and tag completion
is, but maybe other disagree: there's support for it in Cogito, in fact, and
a shortened SHA1 is used as kernel revision.
--
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade
[-- Attachment #2: stg-compl --]
[-- Type: text/plain, Size: 2369 bytes --]
_stg ()
{
local cur cmd cmds
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=()
if [ $COMP_CWORD -eq 1 ]; then
cmds=$(stg help|tail +4|awk '{print $1}')
COMPREPLY=( $(compgen -W "${cmds}" -- $cur) )
else
local cmd=${COMP_WORDS[1]}
local prev=${COMP_WORDS[COMP_CWORD-1]}
#if [ $COMP_CWORD -eq 2 -o "$prev" = "-t" -o "$prev" = "--to" -o "$prev" = "-r" ]; then
local patches
#Add -b support - pass "-b branch" to unapplied and applied.
case $cmd in
push)
patches=$(stg unapplied)
;;
pop|mail)
patches=$(stg applied)
;;
diff|id)
patches=$((stg applied; stg unapplied)|while read i; do echo $i/; done)
;;
esac
case $cmd in
push)
if [ "$prev" = "-t" -o "$prev" = "--to" ]; then
if [ "${cur#*:}" != "${cur}" ]; then
COMPREPLY=( $(compgen -W "${patches}" -- ${cur#*:}) )
else
COMPREPLY=( $(compgen -W "${patches}" -- $cur) )
fi
else
cmds="-a --all -n --number -t --to --reverse --undo -h --help"
COMPREPLY=( $(compgen -W "${cmds} ${patches}" -- $cur) )
fi
;;
pop)
if [ "$prev" = "-t" -o "$prev" = "--to" ]; then
COMPREPLY=( $(compgen -W "${patches}" -- $cur) )
else
cmds="-a --all -n --number -t --to -h --help"
COMPREPLY=( $(compgen -W "${cmds}" -- $cur) )
fi
;;
mail)
if [ "$prev" = "-r" -o "$prev" = "--range" ]; then
if [ "${cur#*:}" != "${cur}" ]; then
COMPREPLY=( $(compgen -W "${patches}" -- ${cur#*:}) )
else
COMPREPLY=( $(compgen -W "${patches}" -- $cur) )
fi
else
cmds="-a --all -r --range --to --cc --bcc -v --version \
-t --template -f --first -s --sleep --refid -u --smtp-user \
-p --smtp-password -b --branch -h --help"
COMPREPLY=( $(compgen -o bashdefault -W "${cmds} ${patches}" -- $cur) )
fi
;;
diff)
if [ "$prev" = "-r" ]; then
if [ "${cur#*:}" != "${cur}" ]; then
COMPREPLY=( $(compgen -W "${patches}" -- ${cur#*:}) )
else
COMPREPLY=( $(compgen -W "${patches}" -- $cur) )
fi
else
cmds="-r -s --stat -h --help"
COMPREPLY=( $(compgen -W "${cmds}" -- $cur) )
fi
;;
id)
cmds="-b --branch -h --help"
COMPREPLY=( $(compgen -W "${cmds} ${patches}" -- $cur) )
;;
*)
COMPREPLY=( $(compgen -f -- $cur) )
;;
esac
#else
#COMPREPLY=( $(compgen -f -- $cur) )
#fi
fi
}
complete -o default -F _stg stg
# vi: set ft=sh:
next reply other threads:[~2005-10-02 11:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-02 11:03 Blaisorblade [this message]
2005-10-02 17:37 ` StGit command completions - and Git ones? Horst von Brand
2005-10-03 17:57 ` Blaisorblade
2005-10-04 7:23 ` Catalin Marinas
2005-10-04 9:57 ` Blaisorblade
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200510021303.44960.blaisorblade@yahoo.it \
--to=blaisorblade@yahoo.it \
--cc=catalin.marinas@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).