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

Request (completions): also complete sessions' names for 'attach' subcommand #1030

Closed
folliehiyuki opened this issue Jan 27, 2022 · 8 comments · Fixed by #1176
Closed

Request (completions): also complete sessions' names for 'attach' subcommand #1030

folliehiyuki opened this issue Jan 27, 2022 · 8 comments · Fixed by #1176
Labels
enhancement New feature or request

Comments

@folliehiyuki
Copy link
Contributor

folliehiyuki commented Jan 27, 2022

This is pretty easy to do on the shell side. For example, in fish:

function __fish_complete_sessions
    zellij list-sessions | sed "/No active zellij sessions found./d"
end
complete -c zellij -n "__fish_seen_subcommand_from attach" -f -a "(__fish_complete_sessions)" -d "Session"

zellij generates completions from subcommands instead of providing the completion files and I don't know Rust :( so I'll leave this feature request here.

@a-kenji
Copy link
Contributor

a-kenji commented Mar 4, 2022

@folliehiyuki,
Thank you for this awesome hint. I would love to integrate something like this.
Is there a way to get the same behaviour without sed?

@folliehiyuki
Copy link
Contributor Author

The sed command is just a hacky way to suppress the output when there is no active session (so that zellij only completes options and help).

Without sed, I'd suggest we move the No active zellij sessions found. output to stderr (make zellij list-sessions throws error and exit 1 when there is no session) and the function above can be changed to zellij list-sessions 2>/dev/null or something similar. This suggestion changes the behavior of zellij so it is subjective.

I can't come up with any better idea right now sadly.

@a-kenji
Copy link
Contributor

a-kenji commented Mar 4, 2022

@folliehiyuki,
No, that is a great idea. Thank you.

Without sed, I'd suggest we move the No active zellij sessions found. output to stderr

That is actually something I wrote on my whiteboard today, since I played around with the attach subcommand earlier. So it is quite awesome that it would also help this issue here.

a-kenji added a commit to a-kenji/zellij that referenced this issue Mar 5, 2022
And infrastructure to make it possible
to add more dynamic completions for
different shells in the future.

eg:

```
zellij attach [completes-active-sessions]
zellij kill-session [completes-active-sessions]
```

fixes: zellij-org#1030
a-kenji added a commit that referenced this issue Mar 5, 2022
And infrastructure to make it possible
to add more dynamic completions for
different shells in the future.

eg:

```
zellij attach [completes-active-sessions]
zellij kill-session [completes-active-sessions]
```

fixes: #1030
@a-kenji
Copy link
Contributor

a-kenji commented Mar 5, 2022

@folliehiyuki,
I just added it to main.
So you could try it out now, or wait for the next release.
Please don't hesitate reaching out again!

@folliehiyuki
Copy link
Contributor Author

@a-kenji I left some minor comments in the commit: e2ce261#r68041355 and e2ce261#r68041394

@a-kenji
Copy link
Contributor

a-kenji commented Mar 5, 2022

@folliehiyuki,
Awesome, thank you so much!

@folliehiyuki
Copy link
Contributor Author

I think the same thing can be achieved with zsh since it can also take a command as argument list. I'm not familiar with zsh though.

Bash probably doesn't support this kind of completion.

@cyruseuros
Copy link

cyruseuros commented Apr 25, 2023

@a-kenji should this be opened as a separate issue for zsh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants