Tab Completion: completer for ls? #2639

Closed
rmcgibbo opened this Issue Dec 3, 2012 · 6 comments

Comments

Projects
None yet
4 participants
@rmcgibbo
Contributor

rmcgibbo commented Dec 3, 2012

%cd has a special tab completer (source at core/completerlib.py:cd_completer, registered with the completer system inside interactiveshell.py).

Which means that with %cd, only directories show up

In[14]: MyValue = 10

In [15]: cd M<TAB>
Mail/    Movies/  Music/  

But with %ls, we're not so fortunate. Python objects show up in addition to files and directories

In [38]: ls M<TAB>
Mail/        MemoryError  Movies/      Music/       MyValue  

This would be an easy feature to add.

@rmcgibbo

This comment has been minimized.

Show comment Hide comment
@rmcgibbo

rmcgibbo Dec 3, 2012

Contributor

Actually... I just checked %lsmagic and it seems I was slightly confused. There is no IPython %ls magic. Instead, because my .bashrc aliases ls to ls -F, it's added to ipython's alias table (would it have been added to the alias table regardless? I'm not sure where the IPython alias table is constructed.)

Even still, should system commands that are available in IPython as automagic-y shell commands (by virtue of being in the alias table or whatever) be given shell-style tab completion?

Contributor

rmcgibbo commented Dec 3, 2012

Actually... I just checked %lsmagic and it seems I was slightly confused. There is no IPython %ls magic. Instead, because my .bashrc aliases ls to ls -F, it's added to ipython's alias table (would it have been added to the alias table regardless? I'm not sure where the IPython alias table is constructed.)

Even still, should system commands that are available in IPython as automagic-y shell commands (by virtue of being in the alias table or whatever) be given shell-style tab completion?

@Carreau

This comment has been minimized.

Show comment Hide comment
@Carreau

Carreau Dec 3, 2012

Member

Le 3 déc. 2012 à 06:28, Robert McGibbon a écrit :

Actually... I just checked %lsmagic and it seems I was slightly confused. There is no IPython %ls magic. Instead, because my .bashrc aliases ls to ls -F, it's added to ipython's alias table (would it have been added to the alias table regardless? I'm not sure where the IPython alias table is constructed.)

Here : IPython/core/alias.py
and yes, ls -F is added by default.

Even still, should system commands that are available in IPython as automagic-y shell commands (by virtue of being in the alias table or whatever) be given shell-style tab completion?

I don't see reason why not, unless they are overwritten by something from user namespace.
But let's not forget that ipython expand python variable for shell aliases.

which allows
In [8]: foobar = '.py'
In [9]: foofoo = '
.js'
In [10]: ls $fo
foofoo foobar

...
In [10]: ls $foofoo
phantomtest.js slideshownew.js

And then it is more helpful /make more sense ....

Matthias


Reply to this email directly or view it on GitHub.

Member

Carreau commented Dec 3, 2012

Le 3 déc. 2012 à 06:28, Robert McGibbon a écrit :

Actually... I just checked %lsmagic and it seems I was slightly confused. There is no IPython %ls magic. Instead, because my .bashrc aliases ls to ls -F, it's added to ipython's alias table (would it have been added to the alias table regardless? I'm not sure where the IPython alias table is constructed.)

Here : IPython/core/alias.py
and yes, ls -F is added by default.

Even still, should system commands that are available in IPython as automagic-y shell commands (by virtue of being in the alias table or whatever) be given shell-style tab completion?

I don't see reason why not, unless they are overwritten by something from user namespace.
But let's not forget that ipython expand python variable for shell aliases.

which allows
In [8]: foobar = '.py'
In [9]: foofoo = '
.js'
In [10]: ls $fo
foofoo foobar

...
In [10]: ls $foofoo
phantomtest.js slideshownew.js

And then it is more helpful /make more sense ....

Matthias


Reply to this email directly or view it on GitHub.

@takluyver

This comment has been minimized.

Show comment Hide comment
@takluyver

takluyver Dec 3, 2012

Member

On 3 December 2012 21:03, Bussonnier Matthias notifications@github.comwrote:

I don't see reason why not, unless they are overwritten by something from
user namespace.
But let's not forget that ipython expand python variable for shell
aliases.

It also expands those variables for cd, so presumably tab completion
doesn't work there. Can it be made smart enough to only tab-complete Python
variables after a $ or { ?

Member

takluyver commented Dec 3, 2012

On 3 December 2012 21:03, Bussonnier Matthias notifications@github.comwrote:

I don't see reason why not, unless they are overwritten by something from
user namespace.
But let's not forget that ipython expand python variable for shell
aliases.

It also expands those variables for cd, so presumably tab completion
doesn't work there. Can it be made smart enough to only tab-complete Python
variables after a $ or { ?

@rmcgibbo

This comment has been minimized.

Show comment Hide comment
@rmcgibbo

rmcgibbo Dec 3, 2012

Contributor

Yeah, definitely can do. I am happy to implement it.

I didn't know that these features existed actually (the $ completion)

If there's any way that someone could write down like a grammer... That would be really helpful. Is there anything like an IPython specific language spec? If not, no big deal.

Contributor

rmcgibbo commented Dec 3, 2012

Yeah, definitely can do. I am happy to implement it.

I didn't know that these features existed actually (the $ completion)

If there's any way that someone could write down like a grammer... That would be really helpful. Is there anything like an IPython specific language spec? If not, no big deal.

@takluyver

This comment has been minimized.

Show comment Hide comment
@takluyver

takluyver Dec 4, 2012

Member

On 3 December 2012 23:42, Robert McGibbon notifications@github.com wrote:

If there's any way that someone could write down like a grammer... That
would be really helpful. Is there anything like an IPython specific
language spec? If not, no big deal.

Not exactly. It's mostly Python, plus:

  • %magics
  • !system commands
  • commands on a single line without an escape character can be magics or
    aliases.
  • All of the above can have Python variables substituted in using $foo or
    {foo} notation
  • ?help/help?/help??
  • %%cell magics (can contain ~ anything)
  • Then there are a variety of special syntaxes for doing function calls,
    using characters like , and ; as prefixes, you can leave out brackets and
    quotation marks. I don't think these are used much now.
  • We also strip prompts - both Python's >>> prompt and our own In [x]:
    prompts.
  • And if your input ends with a ; the output is suppressed.

That's everything I can think of at present.

Member

takluyver commented Dec 4, 2012

On 3 December 2012 23:42, Robert McGibbon notifications@github.com wrote:

If there's any way that someone could write down like a grammer... That
would be really helpful. Is there anything like an IPython specific
language spec? If not, no big deal.

Not exactly. It's mostly Python, plus:

  • %magics
  • !system commands
  • commands on a single line without an escape character can be magics or
    aliases.
  • All of the above can have Python variables substituted in using $foo or
    {foo} notation
  • ?help/help?/help??
  • %%cell magics (can contain ~ anything)
  • Then there are a variety of special syntaxes for doing function calls,
    using characters like , and ; as prefixes, you can leave out brackets and
    quotation marks. I don't think these are used much now.
  • We also strip prompts - both Python's >>> prompt and our own In [x]:
    prompts.
  • And if your input ends with a ; the output is suppressed.

That's everything I can think of at present.

@rmcgibbo

This comment has been minimized.

Show comment Hide comment
@rmcgibbo

rmcgibbo Dec 4, 2012

Contributor

Sweet.

Sent from my iPhone

On Dec 3, 2012, at 4:32 PM, Thomas Kluyver notifications@github.com wrote:

On 3 December 2012 23:42, Robert McGibbon notifications@github.com wrote:

If there's any way that someone could write down like a grammer... That
would be really helpful. Is there anything like an IPython specific
language spec? If not, no big deal.

Not exactly. It's mostly Python, plus:

  • %magics
  • !system commands
  • commands on a single line without an escape character can be magics or
    aliases.
  • All of the above can have Python variables substituted in using $foo or
    {foo} notation
  • ?help/help?/help??
  • %%cell magics (can contain ~ anything)
  • Then there are a variety of special syntaxes for doing function calls,
    using characters like , and ; as prefixes, you can leave out brackets and
    quotation marks. I don't think these are used much now.
  • We also strip prompts - both Python's >>> prompt and our own In [x]:
    prompts.
  • And if your input ends with a ; the output is suppressed.

That's everything I can think of at present.

Reply to this email directly or view it on GitHub.

Contributor

rmcgibbo commented Dec 4, 2012

Sweet.

Sent from my iPhone

On Dec 3, 2012, at 4:32 PM, Thomas Kluyver notifications@github.com wrote:

On 3 December 2012 23:42, Robert McGibbon notifications@github.com wrote:

If there's any way that someone could write down like a grammer... That
would be really helpful. Is there anything like an IPython specific
language spec? If not, no big deal.

Not exactly. It's mostly Python, plus:

  • %magics
  • !system commands
  • commands on a single line without an escape character can be magics or
    aliases.
  • All of the above can have Python variables substituted in using $foo or
    {foo} notation
  • ?help/help?/help??
  • %%cell magics (can contain ~ anything)
  • Then there are a variety of special syntaxes for doing function calls,
    using characters like , and ; as prefixes, you can leave out brackets and
    quotation marks. I don't think these are used much now.
  • We also strip prompts - both Python's >>> prompt and our own In [x]:
    prompts.
  • And if your input ends with a ; the output is suppressed.

That's everything I can think of at present.

Reply to this email directly or view it on GitHub.

@minrk minrk removed the type-enhancement label Jan 14, 2015

@rmcgibbo rmcgibbo closed this Oct 23, 2015

@minrk minrk modified the milestones: no action, wishlist Dec 17, 2015

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