diff options
author | Soispha <soispha@vhack.eu> | 2023-08-19 23:07:51 +0200 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-08-19 23:07:51 +0200 |
commit | a082c240d12541d12969a383d182eaccf913fa32 (patch) | |
tree | 4801d591729178b7030aa56a30b2607b0f328f20 /home-manager/soispha/config/lf/commands/scripts | |
parent | Fix(hm/conf/lf/commands): Correctly quote the id string in 'fzf_jump' cmd (diff) | |
download | nixos-config-a082c240d12541d12969a383d182eaccf913fa32.zip |
Fix(hm/conf/lf): Split file creation and edit of the made file cmds
I mostly create files from vim, thus editing them in the terminal with created them is useless.
Diffstat (limited to 'home-manager/soispha/config/lf/commands/scripts')
-rwxr-xr-x | home-manager/soispha/config/lf/commands/scripts/mk_file | 1 | ||||
-rwxr-xr-x | home-manager/soispha/config/lf/commands/scripts/mk_file_and_edit | 25 |
2 files changed, 25 insertions, 1 deletions
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 |