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 configuration for Bash command line completion #37

Merged
merged 1 commit into from
Oct 21, 2015

Conversation

SpotlightKid
Copy link
Contributor

Fixes #1

I've also added a new command frames to list all frame IDs to support completion for the edit and remove commands. I've put this into an extra commit, so you can choose to include it or not.

Also added some documentation for it in the readme.

@@ -0,0 +1,66 @@
# Bash completion suppoort for watson
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/suppoort/support

@willdurand
Copy link
Contributor

Could you please pass shellcheck on the script file?

@SpotlightKid
Copy link
Contributor Author

I ran shellcheck watson.completion, but the complains it has do not make sense to me:

In watson.completion line 1:
# Bash completion support for watson
^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang.

In watson.completion line 19:
          COMPREPLY=($(compgen -W "-e --edit" -- ${cur})) ;;
                                                 ^-- SC2086: Double quote to prevent globbing and word splitting.
[a lot more of those...]
  1. This is not a script, but a something to be sourced by /etc/bashrc, therefor it has no shebang line.
  2. ${cur} must not be quoted, because COMPREPLY is an array.

@SpotlightKid SpotlightKid force-pushed the feature/bashcompletion branch from e93da03 to 5977263 Compare October 19, 2015 16:24
@willdurand
Copy link
Contributor

Thank you! Looks good to me, so 👍

@jmaupetit
Copy link
Contributor

@SpotlightKid Thank you for this!

Commands and projects completions work just fine, but tags completion does not :( I always have +0 as completion...

FYI my bash release is GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)

@SpotlightKid
Copy link
Contributor Author

Hmm, maybe your version of sed works differently than mine. Look at line 33 or 55 where I use sed too add a plus sign in front of every line returned by watson tags, by using the placeholder \0 for the entire regular expression match. Maybe your sed doesn't support this placeholder?

Can you replace sed 's/.*/+\0/' with awk '$0="+"$0' in both places and see if that works for you?

…ommand.

The new `frames` command lists all frame IDs to support command-line
completion of frame IDs for `edit` and `remove` command.
@SpotlightKid SpotlightKid force-pushed the feature/bashcompletion branch from 5977263 to 4e59318 Compare October 20, 2015 08:56
@willdurand
Copy link
Contributor

@SpotlightKid don't you have to use a group for that? (i.e. adding parenthesis)

@SpotlightKid
Copy link
Contributor Author

In fact, I just noticed that adding plus signs should not be done when completing the argument of the -T option to log and report (line 33). Amended the commit.

@SpotlightKid
Copy link
Contributor Author

@willdurand \0 normally is the entire match. It works on my system (sed (GNU sed) 4.2.2). However, the awk solution should work better, so I used this and squashed the commits again.

@willdurand
Copy link
Contributor

cool! BTW, what's your OS? Because we run OSX here, and there are differences between the unix tools..

@SpotlightKid
Copy link
Contributor Author

Manjaro (Arch Linux derivate)

@jmaupetit
Copy link
Contributor

@SpotlightKid the awk solution works like a charm on OSX!

Thank you so much for this!

jmaupetit added a commit that referenced this pull request Oct 21, 2015
Add configuration for Bash command line completion
@jmaupetit jmaupetit merged commit 56186f1 into jazzband:develop Oct 21, 2015
@SpotlightKid SpotlightKid deleted the feature/bashcompletion branch October 21, 2015 13:00
loonies pushed a commit to loonies/Watson that referenced this pull request Feb 19, 2016
Add configuration for Bash command line completion
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

3 participants