Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In %magic help, remove duplicate aliases #641

Closed
fperez opened this issue Jul 30, 2011 · 2 comments · Fixed by #2036
Closed

In %magic help, remove duplicate aliases #641

fperez opened this issue Jul 30, 2011 · 2 comments · Fixed by #2036
Milestone

Comments

@fperez
Copy link
Member

fperez commented Jul 30, 2011

Certain magics are actually just aliases of another, like %hist and %history. In %magic, we show the full help for both, which can be confusing. We should instead indicate which one is an alias and refer the reader to the original for details.

@bfroehle
Copy link
Contributor

I agree this would be a nice improvement. In terms of implementation, I think it'd be easiest to add an attribute to the function which stored the name of the alias:

    # For a long time we've had %hist as well as %history
    @line_magic
    def hist(self, arg):
        return self.history(arg)

    hist.__doc__ = history.__doc__
    hist._magic_alias = 'history'

Then %magic can just check for fn._magic_alias and print an abbreviated description:

%history:
    Alias for `%hist`.

We could optionally provide a function which did this wrapping automatically:

    hist = line_magic_alias('hist', history)

@fperez
Copy link
Member Author

fperez commented Jun 21, 2012

@bfroehle, +1

This was referenced Jun 22, 2012
@fperez fperez closed this as completed in 37bd8f7 Jun 26, 2012
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
%alias_magic

A magic function which creates additional magic aliases.

* `%alias_magic myedit edit`: `%myedit` is an alias of `%edit`.

* `%alias_magic mybash bash`: `%%mybash` is an alias of `%bash`.

* `%alias_magic mytimeit timeit`: `%mytimeit` is an alias of `%timeit`, and `%%mytimeit` is an alias of `%%timeit`.

* `%alias_magic --cell mytimeit timeit`: Only `%%mytimeit` is an alias of `%timeit`.

Closes ipython#641.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants