Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3393840
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:05:56+00:00 2026-05-18T04:05:56+00:00

In zsh, I have a function called g which acts like this: with no

  • 0

In zsh, I have a function called g which acts like this:

  • with no arguments, call git status
  • with one or more arguments, delegate to git with all given arguments – i.e. call git $@

I would like the tab completions for g to be exactly the same as for git. I can achieve this with alias g=git, but that doesn’t allow me to call status by default (the first point above).

How can I delegate to the completion for git?

In bash, I simply did complete -F _git g which re-uses git’s completion function. With zsh, git’s completion looks much more complex, and I wan’t able to find a similar solution.

I’d guess there’s some function in zsh to say “pretend I typed command [x], what would you complete it to?”. If I knew what that was, it should be simple enough to use a function to delegate to it. But I’ve found no such function in the manuals.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:05:56+00:00Added an answer on May 18, 2026 at 4:05 am

    The documentation for compdef says this:

    The function compdef can be used to associate existing completion functions with new commands. For example,

    compdef _pids foo
    

    But adapting it (_git is the usual completion function for git) did not produce a working result for me (even after _git had been autoloaded):

    compdef _git g
    

    I was able to get it to work via _dispatch though:

    compdef '_dispatch git git' g
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing a little zsh function that checks all of my git repositories
Suppose I have: alias gg=git grep then stuff like: gg int x works, but
I have the following code in my .Zshrc function google; { $VIEW http://www.google.com/search?q='url-encode ${(j:
I use zsh and have the Emacs keybindings set up for it. I'd love
In zsh, how do I pass anonymous arrays into functions? e.g. looking for something
I'm having a rather strange problem with zsh. When I start up my shell,
First, let me state that this is a programming question (and thus does not
I've been Googling for a while looking for a simple way to do this,
I wanted to achieve the same as asked here Saving current directory to bash
I am a happy BASH user. I do not want to switch to another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.