Code Monkey home page Code Monkey logo

sysz's Introduction

A fzf terminal UI for systemctl

Console - Developer Tool of the Week

Demo

asciicast

Features

VERSION: 1.4.3

  • See and filter both system and user units simultaneously.
  • Supports all unit types.
  • Units ordered by service, timer, socket, and the rest.
  • Runs sudo automatically and only if necessary.
  • Filter units by state using ctrl-s or the --state option.
  • Run daemon-reload with ctrl-r.
  • Has short versions of systemctl commands to reduce typing.
  • Runs status after other commands (start, stop, restart, etc).
  • Select multiple units, states, and commands using TAB.
  • Only prompts commands based on current state (e.g. show "start" only if the unit is inactive).

Requirements

  • fzf >= 0.27.1
  • bash > 4.3 (released 2009)
  • awk

Installation

Arch Linux

paru -S sysz

NixOS

nix-env -iA nixos.sysz

Using Nix

nix-env -iA nixpkgs.sysz

Using bin

bin install https://github.com/joehillen/sysz

Direct Download

wget -O ~/.bin/sysz https://github.com/joehillen/sysz/releases/latest/download/sysz
chmod +x ~/.bin/sysz

From Source

git clone https://github.com/joehillen/sysz.git
cd sysz
sudo make install # /usr/local/bin/sysz

Usage

A utility for using systemctl interactively via fzf.

Usage: sysz [OPTS...] [CMD] [-- ARGS...]

sudo is invoked automatically, if necessary.

If only one unit is chosen, available commands will be presented
based on the state of the unit (e.g. "start" only shows if unit is "active").

OPTS:
  -u, --user               Only show --user units
  --sys, --system          Only show --system units
  -s STATE, --state STATE  Only show units in STATE (repeatable)
  -V, --verbose            Print the systemctl command
  -v, --version            Print the version
  -h, --help               Print this message

  If no options are given, both system and user units are shown.

CMD:
  start                  systemctl start <unit>
  stop                   systemctl stop <unit>
  r, restart             systemctl restart <unit>
  s, stat, status        systemctl status <unit>
  ed, edit               systemctl edit <unit>
  reload                 systemctl reload <unit>
  en, enable             systemctl enable <unit>
  d, dis, disable        systemctl disable <unit>
  c, cat                 systemctl cat <unit>

  If no command is given, one or more can be chosen interactively.

ARGS are passed to the systemctl command for each selected unit.

Keybindings:
  TAB           Toggle selection.
  ctrl-v        'cat' the unit in the preview window.
  ctrl-s        Select states to match. Selection is reset.
  ctrl-r        Run daemon-reload. Selection is reset.
  ctrl-p        History previous.
  ctrl-n        History next.
  ?             Show keybindings.

History:
  sysz is stored in $XDG_CACHE_HOME/sysz/history
  This can be changed with the environment variable: SYSZ_HISTORY

Some units are colored based on state:
  green       active
  red         failed
  yellow      not-found

Examples:
  sysz -u                      User units
  sysz --sys -s active          Active system units
  sysz --user --state failed   Failed user units

Examples with commands:
  sysz start                  Start a unit
  sysz --sys s                Get the status of system units
  sysz --user edit            Edit user units
  sysz s -- -n100             Show status with 100 log lines
  sysz --sys -s active stop    Stop an active system unit
  sysz -u --state failed r    Restart failed user units

Acknowledgements

Inspired by fuzzy-sys by NullSense

Thank you for ShellCheck without which this would be a buggy mess.

sysz's People

Contributors

bradym avatar croissong avatar joehillen avatar loicreynier avatar nullsense avatar rothgar avatar savchenko avatar slve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

sysz's Issues

#!/bin/bash is not portable

I suggest you change it to #!/usr/bin/env bash that is specified by POSIX. /bin/bash doesn't work in some Linux systems like NixOS. Otherwise it works great on NixOS, and it's a great tool, thanks.

Journal not working for user service

Issue

Trying to open the journal for a user service, in this case emacs.service, does not show any entries.

Example:

sysz -V
# select emacs -> journal
> journalctl -xe --unit=emacs.service

In comparison, journalctl --user -xe --unit=emacs.service shows logs.

The same issue is present for other user services.

In the code you mentioned

# remove --user flag from journalctl
# --user and --system don't work the same on journalctl

I don't fully understand the actual use cases for the corresponding journactl flags, but i suppose using them 1:1 is incorrect.
What also appears to work though is --user-unit:

journalctl -xe --user-unit=emacs.service

Maybe that's the proper way to select user services?

If you agree with this solution, I can attempt to create a PR for the changes :)

Error when using xonsh as default shell

I have my default shell set to xonsh
Even thought the sysz has #!/usr/bin/env bash, it is somehow invoking $SHELL and I'm getting a traceback error when I press ? to get keybindings. Error goes away when I run sysz with env SHELL=/usr/bin/bash sysz from xonsh. I'm attaching screenshot of traceback from xonsh and you can see its trying to run something from sysz and getting syntax error.
image
(Screenshot because I cannot copy from sysz window)

unknown action: change-prompt(Reload: )

Version 1.3.0 throws an error on ubuntu (fairly normal machine) when trying to run:

unknown action: change-prompt(Reload: )

Reason seems to be this line:

sysz/sysz

Line 385 in 4591797

--bind "ctrl-r:clear-selection+clear-query+change-prompt(Reload: )+close+reload('${BASH_SOURCE[0]}' _fzf_daemon_reload)+first" \

The previous version (1.2.3) works fine. Thanks for this very useful utility!

fzf version

Was there a specific reason for a31f0a8?
Debian currently ships v0.24.3 in Stable which makes sysz incompatible without a manually-built fzf.

$ rmadison fzf
fzf        | 0.24.3-1+b6   | stable     | amd64
fzf        | 0.24.3-1+b6   | testing    | amd64
fzf        | 0.24.3-1+b6   | unstable   | amd64

v1.4.3 wget install issue

I tried using wget to install sysz but the URL given in the README gives a 404 as the sysz binary isn't released as an asset in v1.4.3.

λ wget -O ~/.local/bin/sysz https://github.com/joehillen/sysz/releases/latest/download/sysz
--2021-11-13 22:54:44--  https://github.com/joehillen/sysz/releases/latest/download/sysz
Resolving github.com (github.com)... 13.234.210.38
Connecting to github.com (github.com)|13.234.210.38|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github.com/joehillen/sysz/releases/download/1.4.3/sysz [following]
--2021-11-13 22:54:45--  https://github.com/joehillen/sysz/releases/download/1.4.3/sysz
Reusing existing connection to github.com:443.
HTTP request sent, awaiting response... 404 Not Found
2021-11-13 22:54:45 ERROR 404: Not Found.

Can the binary be added as an asset to the release?

fails to run

Sorry, I gave this a try and it failed to run with this message

unknown action: preview('/usr/local/bin/sysz' _fzf_cat {})

Not very useful, but I've never used fzf so. maybe a newer version is required

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.