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

Add completes for shells by shtab #509

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Freed-Wu
Copy link

@Freed-Wu Freed-Wu commented Aug 28, 2022

ptpython --print-completion bash | sudo tee /usr/share/bash-completion/completions/ptpython
ptpython --print-completion zsh | sed 's/compdef ptpython/compdef -P pt(i|)python[0-9.]#/' | sudo tee /usr/share/zsh/site-functions/_ptpython  # wait <https://github.com/iterative/shtab/issues/87>
ptpython --print-completion tcsh | sudo tee /etc/profile.d/ptpython.completion.csh

Same as inducer/pudb#546. And fix #508

❯ ptpython --print-completion zsh | sed 's/compdef ptpython/compdef -P pt(i|)python[0-9.]#/' | xsel -ib
#compdef -P pt(i|)python[0-9.]#

# AUTOMATCALLY GENERATED by `shtab`


_shtab_ptpython_commands() {
  local _commands=(
    
  )
  _describe 'ptpython commands' _commands
}

_shtab_ptpython_options=(
  "(- : *)"{-h,--help}"[show this help message and exit]"
  "(- : *)--print-completion[print shell completion script]:print_completion:(bash zsh tcsh)"
  "--vi[Enable Vi key bindings]"
  {-i,--interactive}"[Start interactive shell after executing this file.]"
  "--light-bg[Run on a light background (use dark colors for text).]"
  "--dark-bg[Run on a dark background (use light colors for text).]"
  "--config-file[Location of configuration file.]:config_file:_files -g *.py"
  "--history-file[Location of history file.]:history_file:_files"
  "(- : *)"{-V,--version}"[show program\'s version number and exit]"
  "(-)*:Script and arguments:_script_args"
)


_shtab_ptpython() {
  local context state line curcontext="$curcontext"

  local one_or_more='(-)*'
  local reminder='(*)'
  if ((${_shtab_you_get_options[(I)${(q)one_or_more}*]} + ${_shtab_you_get_options[(I)${(q)reminder}*]} == 0)); then  # noqa: E501
    _shtab_ptpython_options+=(': :_shtab_ptpython_commands' '*::: :->ptpython')
  fi
  _arguments -C $_shtab_ptpython_options

  case $state in
    ptpython)
      words=($line[1] "${words[@]}")
      (( CURRENT += 1 ))
      curcontext="${curcontext%:*:*}:_shtab_ptpython-$line[1]:"
      case $line[1] in
        
      esac
  esac
}

# Custom Preamble
_script_args() {
  _arguments -S -s '(-)1:script_args:_files -g *.py' '*: :_files'
}

# End Custom Preamble


typeset -A opt_args
_shtab_ptpython "$@"

ptpython --print-completion bash | sudo tee /usr/share/bash-completion/completions/ptpython
ptpython --print-completion zsh | sed 's/compdef ptpython/compdef -P pt(i|)python[0-9.]#/' | sudo tee /usr/share/zsh/site-functions/_ptpython  # wait <iterative/shtab#87>
ptpython --print-completion tcsh | sudo tee /etc/profile.d/ptpython.completion.csh
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.

[bug] "*" should be argparse.REMINDER
1 participant