Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

systemctl completions: add cat & edit commands#3757

Merged
faho merged 3 commits into
fish-shell:masterfish-shell/fish-shell:masterfrom
nim65s:masternim65s/fish-shell:masterCopy head branch name to clipboard
Feb 2, 2017
Merged

systemctl completions: add cat & edit commands#3757
faho merged 3 commits into
fish-shell:masterfish-shell/fish-shell:masterfrom
nim65s:masternim65s/fish-shell:masterCopy head branch name to clipboard

Conversation

@nim65s

@nim65s nim65s commented Jan 22, 2017

Copy link
Copy Markdown
Contributor

This just adds autocompletions for "new" subcommands systemctl cat & systemctl edit.

@zanchey

zanchey commented Jan 22, 2017

Copy link
Copy Markdown
Member

Do we need to add version detection for systemctl to make sure fish doesn't suggest options that aren't available?

@nim65s

nim65s commented Jan 24, 2017

Copy link
Copy Markdown
Contributor Author

edit appeared in 218 (https://github.com/systemd/systemd/blob/master/NEWS#L2445)
cat appeared in 209 (https://github.com/systemd/systemd/blob/master/NEWS#L4155)
systemd --version gives systemd 232 (and another line with compilation options)
So I guess it is not hard to add this check.

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 :)

@faho

faho commented Jan 24, 2017

Copy link
Copy Markdown
Member

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 systemctl, not systemd, since that's not commonly in $PATH.

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.

@faho faho added this to the next-minor milestone Jan 24, 2017
@nim65s

nim65s commented Jan 25, 2017

Copy link
Copy Markdown
Contributor Author

Done :)
What do you think ?

Comment thread share/completions/systemctl.fish Outdated
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'

Copy link
Copy Markdown
Member

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!

Comment thread share/completions/systemctl.fish Outdated
@@ -1,8 +1,15 @@
set -l systemd_version (systemctl --version | head -n 1 | cut -f 2 -d ' ')

Copy link
Copy Markdown
Member

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'?

@nim65s

nim65s commented Jan 25, 2017

Copy link
Copy Markdown
Contributor Author

Thanks, TIL string function & english 🎉

@faho
faho merged commit b7cdb6d into fish-shell:master Feb 2, 2017
@faho

faho commented Feb 2, 2017

Copy link
Copy Markdown
Member

Thanks, merged!

@@ -1,8 +1,15 @@
set -l systemd_version (systemctl --version | string match "systemd*" | string replace -r "\D*(\d+)" '$1')

Copy link
Copy Markdown
Member

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

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.