about summary refs log tree commit diff stats
path: root/home-manager
diff options
context:
space:
mode:
Diffstat (limited to 'home-manager')
-rw-r--r--home-manager/soispha/config/lf/commands/default.nix5
-rwxr-xr-xhome-manager/soispha/config/lf/commands/scripts/mk_file1
-rwxr-xr-xhome-manager/soispha/config/lf/commands/scripts/mk_file_and_edit25
-rw-r--r--home-manager/soispha/config/lf/keybindings/default.nix1
4 files changed, 31 insertions, 1 deletions
diff --git a/home-manager/soispha/config/lf/commands/default.nix b/home-manager/soispha/config/lf/commands/default.nix
index c60b0039..c8652442 100644
--- a/home-manager/soispha/config/lf/commands/default.nix
+++ b/home-manager/soispha/config/lf/commands/default.nix
@@ -18,6 +18,7 @@
       inherit replacementStrings;
     }
     + "/bin/${builtins.baseNameOf file}";
+
   shell = {
     file,
     dependencies,
@@ -143,6 +144,10 @@ in {
     file = ./scripts/mk_file;
     dependencies = [];
   };
+  mk_file_and_edit = shell {
+    file = ./scripts/mk_file_and_edit;
+    dependencies = [];
+  };
   mk_ln = pipe {
     file = ./scripts/mk_ln;
     dependencies = [];
diff --git a/home-manager/soispha/config/lf/commands/scripts/mk_file b/home-manager/soispha/config/lf/commands/scripts/mk_file
index 2e5a2deb..5f245396 100755
--- a/home-manager/soispha/config/lf/commands/scripts/mk_file
+++ b/home-manager/soispha/config/lf/commands/scripts/mk_file
@@ -21,5 +21,4 @@ do
 done
 
 touch "$name"
-"$EDITOR" "$name"
 # vim: ft=sh
diff --git a/home-manager/soispha/config/lf/commands/scripts/mk_file_and_edit b/home-manager/soispha/config/lf/commands/scripts/mk_file_and_edit
new file mode 100755
index 00000000..2e5a2deb
--- /dev/null
+++ b/home-manager/soispha/config/lf/commands/scripts/mk_file_and_edit
@@ -0,0 +1,25 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+prompt "File name: "
+name=""
+while [ -z "$name" ] || [ -e "$name" ]
+do
+  read -r name
+  if [ -e "$name" ]; then
+    prompt "File already exists, overwrite [y|N]: "
+    read -r ans
+
+    if [ "$ans" = "y" ]; then
+      break
+    else
+      prompt "File name: "
+    fi
+  fi
+done
+
+touch "$name"
+"$EDITOR" "$name"
+# vim: ft=sh
diff --git a/home-manager/soispha/config/lf/keybindings/default.nix b/home-manager/soispha/config/lf/keybindings/default.nix
index bd11f3e3..34286944 100644
--- a/home-manager/soispha/config/lf/keybindings/default.nix
+++ b/home-manager/soispha/config/lf/keybindings/default.nix
@@ -54,6 +54,7 @@
 
   mk = "mk_ln";
   mf = "mk_file";
+  me = "mk_file_and_edit";
   md = "mk_dir";
   ms = "mk_scr_default";
   mt = "mk_scr_temp";