In zsh,
alias ggg='alias -m "g*"'
Or use a function, so that ggg doesn't print itself:
ggg() alias -m 'g*'
You could also grep the output of "alias", but it may not work properly if there are some multi-line aliases.
With bash, you could use this trick:
(
alias() { [[ $1 = g* ]] && builtin alias "${1%%=*}"; }
eval "$(builtin alias)"
)
The idea being that bash's alias outputs some text that is ready to be interpreted to reproduce the same aliases, something like:
$ alias
alias a='foo'
alias goo='gar
baz
alias gro=grar'
So we do evaluate it, but after having redefined alias as a function that calls the real alias only when passed a string that starts with "g".
alias | grep ^goutput? – Gilles Nov 24 '12 at 14:45