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
systemctl completions: add cat & edit commands #3757
Conversation
Do we need to add version detection for systemctl to make sure fish doesn't suggest options that aren't available? |
But I don't know if we "need" to add this check, and I don't know which distributions are using which versions of systemd… So I guess it's up to you. If you want this feature, I can include it in this PR :) |
Yes, please add the check. Though please use While you are at it, there are a couple of options at the bottom with a comment that states they are new since 220. They should be version-guarded as well. |
Done :) |
set -l commands_types start stop restart try-restart reload-or-restart reload-or-try-restart is-active is-failed is-enabled reenable mask loaded link list-dependencies show status | ||
|
||
if test $systemd_version -gt 208 | ||
complete -f -c systemctl -n "not __fish_seen_subcommand_from $commands" -a cat -d 'Show an unit' |
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.
For the purposes of "a"/"an", "u" is a consonant, so this is "Show a unit". Sorry, english is weird!
@@ -1,8 +1,15 @@ | |||
set -l systemd_version (systemctl --version | head -n 1 | cut -f 2 -d ' ') |
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.
I'd prefer this to be done with string
- systemctl --version | string match "systemd*" | string replace -r "\D*(\d+)" '$1'
?
Thanks, TIL |
Thanks, merged! |
@@ -1,8 +1,15 @@ | |||
set -l systemd_version (systemctl --version | string match "systemd*" | string replace -r "\D*(\d+)" '$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.
If there is no systemctl
command, you're going to get a lot of errors. This will go away when we stop loading completion scripts for non-existing commands.
/usr/local/Cellar/fish/HEAD-47ad707/share/fish/completions/systemctl.fish (line 1): systemctl --version | string match "systemd*" | string replace -r "\D*(\d+)" '$1'
^
in command substitution
called on line -1 of file /usr/local/Cellar/fish/HEAD-47ad707/share/fish/completions/systemctl.fish
from sourcing file /usr/local/Cellar/fish/HEAD-47ad707/share/fish/completions/systemctl.fish
called on standard input
in command substitution
called on standard input
test: Missing argument at index 2
test: Missing argument at index 2
test: Missing argument at index 2
This just adds autocompletions for "new" subcommands
systemctl cat
&systemctl edit
.