From c9af4dd8d83bd02b9507fe9e056fa0ac5f608540 Mon Sep 17 00:00:00 2001 From: Linnnus Date: Sat, 16 Nov 2024 13:36:59 +0100 Subject: pkgs: Add nowrap --- pkgs/nowrap/default.nix | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 pkgs/nowrap/default.nix (limited to 'pkgs/nowrap/default.nix') diff --git a/pkgs/nowrap/default.nix b/pkgs/nowrap/default.nix new file mode 100644 index 0000000..cb6672c --- /dev/null +++ b/pkgs/nowrap/default.nix @@ -0,0 +1,28 @@ +{ + writeTextFile, + python3, + lib, +}: +writeTextFile { + name = "nowrap"; + + text = '' + #!${python3.interpreter} + + import sys + import os + + cols = os.get_terminal_size().columns + + for line in sys.stdin: + line = line.removesuffix("\n") + print(line[:cols]) + ''; + executable = true; + destination = "/bin/nowrap"; + + meta = with lib; { + description = "Truncates lines from stdin such that they are no wider than the terminals width"; + mainProgram = "nowrap"; + }; +} -- cgit v1.2.3