From 3a0713ce08f14525e1cb5e645cf411a07d6ccb19 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Wed, 21 Aug 2024 17:29:54 +0200 Subject: fix(pkgs/ll): Ensure that the last_directory save dir exists --- pkgs/by-name/ll/ll/ll.sh | 1 + pkgs/by-name/ll/lm/lm.sh | 12 ------------ pkgs/by-name/ll/lm/package.nix | 9 --------- pkgs/by-name/lm/lm/lm.sh | 12 ++++++++++++ pkgs/by-name/lm/lm/package.nix | 9 +++++++++ 5 files changed, 22 insertions(+), 21 deletions(-) delete mode 100755 pkgs/by-name/ll/lm/lm.sh delete mode 100644 pkgs/by-name/ll/lm/package.nix create mode 100755 pkgs/by-name/lm/lm/lm.sh create mode 100644 pkgs/by-name/lm/lm/package.nix (limited to 'pkgs/by-name') diff --git a/pkgs/by-name/ll/ll/ll.sh b/pkgs/by-name/ll/ll/ll.sh index 9bec7eaf..73328e3e 100755 --- a/pkgs/by-name/ll/ll/ll.sh +++ b/pkgs/by-name/ll/ll/ll.sh @@ -9,6 +9,7 @@ command lf -last-dir-path="$last_directory" "$@" dir="$(cat "$last_directory")" if cd "$dir"; then + [ -d "$XDG_RUNTIME_DIR/ll" ] || mkdir "$XDG_RUNTIME_DIR/ll" echo "$dir" >"$XDG_RUNTIME_DIR/ll/last_directory" else die "$dir does not exist!" diff --git a/pkgs/by-name/ll/lm/lm.sh b/pkgs/by-name/ll/lm/lm.sh deleted file mode 100755 index 55be0798..00000000 --- a/pkgs/by-name/ll/lm/lm.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/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 deleted file mode 100644 index ef417cd2..00000000 --- a/pkgs/by-name/ll/lm/package.nix +++ /dev/null @@ -1,9 +0,0 @@ -{sysLib}: -sysLib.writeShellScript { - name = "lm"; - src = ./lm.sh; - generateCompletions = false; - - # `ll` must be able to change the path of the running shell. - wrap = false; -} diff --git a/pkgs/by-name/lm/lm/lm.sh b/pkgs/by-name/lm/lm/lm.sh new file mode 100755 index 00000000..d5fdca10 --- /dev/null +++ b/pkgs/by-name/lm/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 saved (try using ll instead)." +fi +# vim: ft=sh diff --git a/pkgs/by-name/lm/lm/package.nix b/pkgs/by-name/lm/lm/package.nix new file mode 100644 index 00000000..ef417cd2 --- /dev/null +++ b/pkgs/by-name/lm/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; +} -- cgit 1.4.1