-
Notifications
You must be signed in to change notification settings - Fork 388
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 tmux completion #81
Conversation
This is adapted from the following project: https://github.com/srsudar/tmux-completion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bunch of comments posted. But first, most importantly, have you asked if the tmux project would be interested in including this with tmux itself?
Wrt testing, see doc/testing.txt
_init_completion || return | ||
|
||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting COMPREPLY and cur here are not necessary
|
||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
onePrev="${COMP_WORDS[COMP_CWORD-1]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is onePrev different from the already existing $prev?
cur="${COMP_WORDS[COMP_CWORD]}" | ||
onePrev="${COMP_WORDS[COMP_CWORD-1]}" | ||
|
||
if [ "$COMP_CWORD" -ge 2 ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use $cword instead of $COMP_CWORD
windowCommands=("ls", "list-sessions") | ||
|
||
prev="${COMP_WORDS[COMP_CWORD-2]}" | ||
if [ "$prev" = "attach" ] || [ "$prev" = "attach-session" ] ; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use words instead of COMP_WORDS and cword instead of COMP_CWORD. Also, rename this to something like preprev instead of overloading the usual definition of prev
if [ "$prev" = "attach" ] || [ "$prev" = "attach-session" ] ; then | ||
if [ "$onePrev" = "-t" ] ; then | ||
# Get a list of all session names. | ||
# We're assuming this output is in the form: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like there's a missing indent step within the if block here
fi | ||
|
||
opts=" \ | ||
attach-session \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big fan of this long hardcoded list in the first place. Can't it be generated from somewhere?
If not, please indent the options, and the backslashes are unnecessary I think.
unlink-window \ | ||
up-pane" | ||
|
||
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$cur in double quotes
|
||
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) | ||
return | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary return and empty line
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) | ||
return | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"} &&" here, see existing completions
@@ -0,0 +1,134 @@ | |||
# tmux(1) completion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing -*- shell-script -*-
, see existing completions
I hadn't even thought to check if tmux wanted to incorporate it. Looking at their repo I see that in their README they link to another repo that provides tmux-specific completion. That pointer, along with this closed issue, make it sound like they aren't keen on including the completions as part of tmux. Would you prefer I ask explicitly before considering an eventual merge? The completion script they link to looks like it attempts to do more things than this PR, but it is giving me errors when I try to use it. Since they recommend that one in their documentation, however, maybe accepting something like this would constitute a break from their semi-official completion? Would that preclude a merge? |
I suggest you work with upstream and the other tmux completion author first. I cannot comment on their wishes and practices as I'm not at all involved with those projects, but It's generally the better the closer to upstream packages completions are kept. That way for instance some things can be hardcoded in the completion (e.g. the option list: if the completion was shipped with tmux, it could be easily kept up to date with the tmux version it ships), which is not a luxury we have in bash-completion. Also, more importantly, a maintainer who is actively using the completion is a good thing to have, if not a necessity. I'm not a tmux user and there are no other active project members at the moment. Closing at least for now, post a note here if things don't work out with upstream and the other recommended tmux completion author. But be prepare to make a case for inclusion here, I'm reluctant to add another completion in bash-completion over upstream tmux recommendations and for the reasons outlined above. |
All of those seem like compelling points to me. No worries. |
@srsudar Hi. I am current maintainer of tmux-bash-completion. What errors are you having? You can submit your issues here https://github.com/imomaliev/tmux-bash-completion/issues. |
I decided not to open an issue because I only tried very briefly and I wasn't sure it was a problem with the project rather than my setup. I'll open an issue there just so you can respond and this doesn't linger as something unaddressed about the project. =) |
Opened an issue. |
I just corresponded with the tmux developer, and confirmed that he has no interest in having his repository host a bash completion script. I recently wrote a very comprehensive one, and can offer it to this project. In reading the prior comments on this thread, I see a reference to another tmux-completion repository, so I looked there, and mine is way more comprehensive. If you're interested, I can make a PR. |
@Boruch-Baum Hi, I am currently maintaining bash-completion script for |
@imomaliev : Hi! I don't mind sharing. My preference is for my code contribution to be widely distributed (as long as it works well). If the 'bash completion' accepts my work, then it automatically is included in the debian and other repositories and for anyone who has the package, it will 'just work' without having to search the internet, and manually maintain the file. |
I agree that generally hosting a completion with us here is the 2nd best option to having it upstream. So my suggestion for you is to:
|
@scop @imomaliev @jackfletch : Jack Fletcher's comment finally got me to at least post my work, but I'm not available now for the back-and-forth that @scop is suggesting, so if someone else will carry the ball on it, great. See here. |
Any progress on this front? I'm slowly starting to use tmux myself, so would have more incentive to help out. |
On 2020-04-19 00:02, Ville Skyttä wrote:
Any progress on this front? I'm slowly starting to use tmux myself, so
would have more incentive to help out.
@scop: Likewise, I've received no response to the work[1] that I
published six months ago and referenced here[2]. It's a complete
implementation in a single file, so you should be able to just drop it
into your bash-completion folder and benefit from it.
1] https://github.com/Boruch-Baum/tmux_bash_completion
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
|
I would gladly help with making this completion file https://github.com/imomaliev/tmux-bash-completion part of bash-completion upstream, or any other file chosen as base for this |
Of course I won't do something like that, we have a project that hosts and ships completions here :) Personally I only use completions that are shipped along with the respective upstream tools, or ones we ship here, to maximize sharing the benefit to others. |
Since you're the only one who promised active help within these past two weeks, if you are available also to help out by maintaining the file within bash-completion in long term starting when it's in (I'll give you contributor access for that), you get to choose the base implementation. If you agree, feel free to post a PR and let's start working on it. |
The above comment doesn't BTW mean that others would not be welcome to help out too, and I'll gladly give collaborator access to people now and later who do good work and can show some, are willing to commit to the project's ways, and intend to be available to help out in longer term. I just want to have someone (or more) active here besides myself to drive the inciusion. |
If there are no new collaborators, on this issue, I think I will have time next week to start working on this |
This is adapted from the following project:
https://github.com/srsudar/tmux-completion
I've tried to follow the contributing guidelines and similar PRs that add a file. My
bash
knowledge is sufficiently low that some of the contributing guidelines are over my head. If I'm missing any I apologize.Do you have any documentation on the testing framework you're using so I can write tests? Or a pointer to a command with a minimal test that can serve as an example?