summaryrefslogtreecommitdiff
path: root/pkgs
diff options
context:
space:
mode:
authorLinnnus <[email protected]>2024-11-16 13:36:59 +0100
committerLinnnus <[email protected]>2024-11-16 13:36:59 +0100
commitc9af4dd8d83bd02b9507fe9e056fa0ac5f608540 (patch)
tree242cb2dfbf59adbc66da8a4a6b69f4f7531db3c0 /pkgs
parent18336d643163a6b339f6198c7f53b109ee58bdf7 (diff)
pkgs: Add nowrap
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/default.nix2
-rw-r--r--pkgs/nowrap/default.nix28
2 files changed, 30 insertions, 0 deletions
diff --git a/pkgs/default.nix b/pkgs/default.nix
index bc17038..d7a9f19 100644
--- a/pkgs/default.nix
+++ b/pkgs/default.nix
@@ -27,6 +27,8 @@ pkgs: {
disable-sleep = pkgs.callPackage ./disable-sleep {};
+ nowrap = pkgs.callPackage ./nowrap {};
+
# TODO: These should be contained in the 'vimPlugins' attrset. This turns out
# to be non-trivial because this module is both consumed in a flake output
# context and an overlay context.
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";
+ };
+}