about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-21 15:18:34 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-21 15:25:24 +0200
commit145cc8ec9354443744dfff8d05e966a8bc9b9294 (patch)
tree165de498b138b9721d61512d64acd9ec70efb3cc
parentfeat(home/yt): Init config files (diff)
downloadnixos-config-145cc8ec9354443744dfff8d05e966a8bc9b9294.tar.gz
nixos-config-145cc8ec9354443744dfff8d05e966a8bc9b9294.zip
feat(pkgs/lm): Init and use in pkgs
Diffstat (limited to '')
-rw-r--r--modules/home/pkgs/default.nix9
-rwxr-xr-xpkgs/by-name/ll/ll/ll.sh8
-rwxr-xr-xpkgs/by-name/ll/lm/lm.sh12
-rw-r--r--pkgs/by-name/ll/lm/package.nix9
4 files changed, 29 insertions, 9 deletions
diff --git a/modules/home/pkgs/default.nix b/modules/home/pkgs/default.nix
index e4c62b73..4121337c 100644
--- a/modules/home/pkgs/default.nix
+++ b/modules/home/pkgs/default.nix
@@ -121,13 +121,7 @@ with pkgs; let
 
       YouTube = [
         yti # Wrapper around `yt-dlp`.
-        ytcc # Command line tool to keep track of your favorite playlists on YouTube and many other places.
-        comments # Display comments of the currently playing video.
-        description # Display the description of the currently playing video.
-
-        yt.ytc # Download and watch a video from YouTube.
-        yt.yts # Select videos from the subscribed channels to watch.
-        yt.yt # Combination of `ytc` and `yts` that selects _and_ downloads videos.
+        yt # A command line YouTube client
       ];
 
       Listen = [
@@ -189,6 +183,7 @@ with pkgs; let
       fzf # used to quickly move around with its keybindings
       file # Show information about a file
       ll # Wrapper around `lf` to automatically change the path
+      lm # Wrapper around `ll` to automatically cd to the last accessed path
       show # Wrapper around `less` to show a file (similar to the `cat <FILE>` pattern).
     ];
 
diff --git a/pkgs/by-name/ll/ll/ll.sh b/pkgs/by-name/ll/ll/ll.sh
index f689ba44..9bec7eaf 100755
--- a/pkgs/by-name/ll/ll/ll.sh
+++ b/pkgs/by-name/ll/ll/ll.sh
@@ -8,7 +8,11 @@ last_directory="$(mktemp)"
 command lf -last-dir-path="$last_directory" "$@"
 
 dir="$(cat "$last_directory")"
-cd "$dir" || die "$dir does not exist!"
-rm "$last_directory"
+if cd "$dir"; then
+    echo "$dir" >"$XDG_RUNTIME_DIR/ll/last_directory"
+else
+    die "$dir does not exist!"
+fi
 
+rm "$last_directory"
 # vim: ft=sh
diff --git a/pkgs/by-name/ll/lm/lm.sh b/pkgs/by-name/ll/lm/lm.sh
new file mode 100755
index 00000000..55be0798
--- /dev/null
+++ b/pkgs/by-name/ll/lm/lm.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH
+
+if [ -f "$XDG_RUNTIME_DIR/ll/last_directory" ]; then
+    last_dir="$(cat "$XDG_RUNTIME_DIR/ll/last_directory")"
+    cd "$last_dir" || die "$last_dir does not exist!"
+else
+    msg "No last directory safed (try using ll instead)."
+fi
+# vim: ft=sh
diff --git a/pkgs/by-name/ll/lm/package.nix b/pkgs/by-name/ll/lm/package.nix
new file mode 100644
index 00000000..ef417cd2
--- /dev/null
+++ b/pkgs/by-name/ll/lm/package.nix
@@ -0,0 +1,9 @@
+{sysLib}:
+sysLib.writeShellScript {
+  name = "lm";
+  src = ./lm.sh;
+  generateCompletions = false;
+
+  # `ll` must be able to change the path of the running shell.
+  wrap = false;
+}