Sysz – An fzf terminal UI for systemctl
github.com
github.com
_sysz_list_units |
fzf \
--exact \
--multi \
--ansi \
--reverse \
--no-sort \
--history="$SYSZ_HISTORY" \
--prompt="Units: " \
--bind "ctrl-v:preview('${BASH_SOURCE[0]}' _fzf_cat {})" \
--preview="'${BASH_SOURCE[0]}' _fzf_preview {}" \
--preview-window=70% |
readarray -t PICKS
This is the whole UI. Just give it a list of things to search through, a prompt, and a command for previewing the thing and fzf handles literally all the rest of the UI for you.This achieves something similar but it also does a whole lot more than just help complete the name.
Edit: Helps to have bash-completion working properly for the user :).
systemd: /usr/share/bash-completion/completions/systemctlThis host has bash 4.4.23 and systemd 247.6
(It looks like the person I replied to had an issue with his own profile files rather than a distro issue.)
https://news.ycombinator.com/item?id=28577337
Checkout Daniel's other scripts: https://github.com/DanielFGray/fzf-scripts
apropos -s 2 '.*' | fzf --height=100% --preview-window=down:wrap --preview='man -s 2 {1}' --bind='alt-v:execute(man -s 2 {1}),enter:execute(man -s 2 {1})'
You can also use it with rlwrap for browsing commandline history of arbitrary REPLs (https://github.com/hanslub42/rlwrap/blob/fb60c9aa7579d6b68f2...)
Fzf is wonderful.
$ be rspec spec/**{tab}
Fzf will open inline, select the file(s) you want and run them (like this https://asciinema.org/a/mYTmT908gvVxZTMAsfPxltULx)To get this to work I had to add this line to my .zshrc
source /usr/share/zsh/site-functions/fzf
From the manual:
If set, the pattern ‘*’ used in a filename expansion context will match all files and zero or more directories and subdirectories. If the pattern is followed by a ‘/’, only directories and subdirectories match.
To enable:
$ shopt -s globstar
To disable: $ shopt -u globstar(I tried installing an oh-my-fish theme with such a prompt, but it required Powerline fonts, which I can't get to work.)
So never? Because systemctl by default triggers a PolicyKit prompt when run without sufficient privileges. sudo is entirely unnecessary.