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

improvements to bash completion #4528

Merged
merged 5 commits into from Nov 14, 2013
Merged

Conversation

ivanov
Copy link
Member

@ivanov ivanov commented Nov 13, 2013

[x] added nbconvert and history subcommands

[x] generalized subcommand completer logic

[x] profile, history, locate commands now have completions

[x] bash completion: ipython shows only subcmds

If a partial filename, or an flag or option argument is invoked, those
completions will still take place, but by default, to aid the user in the
discovery of subcommands, pressing tab immediately after ipython will list
only the subcommands as possible completions

If a partial filename, or an flag or option argument is invoked, those
completions will still take place, but by default, to aid the user in
the discovery of subcommands, pressing tab immediately after ipython
will list *only* the subcommands as possible completions
@ivanov
Copy link
Member Author

ivanov commented Nov 13, 2013

pinging @juliantaylor who wrote the original completer, and @ngoldbaum, who was the last to poke at it to enable zsh completion

@ngoldbaum
Copy link
Contributor

This is a significant usability improvement. Works just fine under zsh.

@Carreau
Copy link
Member

Carreau commented Nov 13, 2013

+1

@juliantaylor
Copy link
Contributor

looks nice, maybe one could add this to the subcommand completion to get a space after them:

        if [ "$COMP_CWORD" == 1 ]; then
            local IFS=$'\t\n'
            local sub=$(echo $subcommands | sed -e "s/ / \t/g")
            COMPREPLY=( $(compgen -W "${sub}" -- ${cur}) )

@ivanov
Copy link
Member Author

ivanov commented Nov 13, 2013

Thanks @juliantaylor, I played with it a bit trying to get this functionality yesterday, but couldn't get a clean enough of a patch. Your solution works nicely, so I've added that to this PR.

@ngoldbaum
Copy link
Contributor

EDIT: disregard this, I made a mistake applying the patch.

Hmm, the patch @ivanov just applied broke completion for me. Perhaps I've messed something up - can someone else reproduce this? It behaves the same in bash and zsh, as far as I can tell.

$ ipython note<tab>

$ ipython notebook qtconsole console kernel profile locate history nbconvert

Before the patch, I got a nice ordered list:

$ ipython <tab><tab>
console    kernel     nbconvert  profile
history    locate     notebook   qtconsole
$ ipython 

or a sensible completion:

$ ipython note<tab>

$ ipython notebook

@juliantaylor
Copy link
Contributor

works for me

@ngoldbaum
Copy link
Contributor

Hmm, please disregard my last comment, it looks like I messed something up last night.

ivanov added a commit that referenced this pull request Nov 14, 2013
improvements to bash completion
@ivanov ivanov merged commit e89ef78 into ipython:master Nov 14, 2013
@ivanov ivanov deleted the completion-update branch November 14, 2013 19:06
@jakobgager
Copy link
Contributor

I'm really exited that the bash completion has been updated, however, you missed to add the options for nbconvert!
Simply add nbconvert in line 49.

@ivanov
Copy link
Member Author

ivanov commented Nov 14, 2013

sweet, I've got another PR coming that improves bash completion in other ways, so I'll add it to that one, thanks, @jakobgager

ivanov added a commit to ivanov/ipython that referenced this pull request Nov 14, 2013
thanks @jakobgager for pointing this out in ipython#4528
@jakobgager
Copy link
Contributor

I also tried to write such an update (see https://github.com/jakobgager/IPy_bash_complete).
I included subcommand sensitive completions like --to=<tab> gives latex, html, etc and even --post=<tab> -> pdf, serve (pdf if --to=latex has been specified, and serve if --to=html).

Unfortunately, I didn't succeeded to implement
-<tab> lists the options of --help, whereas
--<tab> lists the options of --help-all
This way the output would be less cluttered and easier to use.

minrk added a commit that referenced this pull request Nov 22, 2013
new `ipython history clear` subcommand

This new subcommand is equivalent to ipython history trim --HistoryTrim.keep=0, which is now supported (and also has a more convenient --keep alias)

This command comes with a fix to bash completion of flags for ipython history subcmd

also included is a tiny fix for nbconvert completion that was pointed out by @jakobgager in #4528

also included is a change to our utils.io.ask_yes_no function that allows for specifying the behavior of a KeyboardInterrupt.
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
thanks @jakobgager for pointing this out in ipython#4528
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
new `ipython history clear` subcommand

This new subcommand is equivalent to ipython history trim --HistoryTrim.keep=0, which is now supported (and also has a more convenient --keep alias)

This command comes with a fix to bash completion of flags for ipython history subcmd

also included is a tiny fix for nbconvert completion that was pointed out by @jakobgager in ipython#4528

also included is a change to our utils.io.ask_yes_no function that allows for specifying the behavior of a KeyboardInterrupt.
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 this pull request may close these issues.

None yet

5 participants