From 025a2c457ef93c4a752882cb065ee2ce41f91e18 Mon Sep 17 00:00:00 2001 From: Akemi Izuko Date: Mon, 19 Dec 2022 20:19:18 -0700 Subject: [PATCH] Integrate file renaming script to vifm --- bin/rename_for_shell.sh | 2 +- vifm/scripts/vifm_bg_open.sh | 2 +- vifm/scripts/vifm_rename_and_move_file.sh | 12 ++++++++++++ vifm/vifmrc | 9 ++------- 4 files changed, 16 insertions(+), 9 deletions(-) create mode 100755 vifm/scripts/vifm_rename_and_move_file.sh diff --git a/bin/rename_for_shell.sh b/bin/rename_for_shell.sh index 3d2b9ae..6f47f85 100755 --- a/bin/rename_for_shell.sh +++ b/bin/rename_for_shell.sh @@ -22,7 +22,7 @@ else if (!length(name) && c == "-") continue; - else if (c ~ /[0-9A-Za-z_.-\/]/) + else if (c ~ /[0-9A-Za-z_.\-\/]/) name = name c else if (c == " ") name = name "_" diff --git a/vifm/scripts/vifm_bg_open.sh b/vifm/scripts/vifm_bg_open.sh index 4dd6845..d1bbc7a 100755 --- a/vifm/scripts/vifm_bg_open.sh +++ b/vifm/scripts/vifm_bg_open.sh @@ -16,7 +16,7 @@ requires_gui_error() { } open_pdf() { - zathura "$1" & + zathura "$1" &>/dev/null & } open_image() { diff --git a/vifm/scripts/vifm_rename_and_move_file.sh b/vifm/scripts/vifm_rename_and_move_file.sh new file mode 100755 index 0000000..a154928 --- /dev/null +++ b/vifm/scripts/vifm_rename_and_move_file.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +declare newname +newname="$(~/.configs_pointer/bin/rename_for_shell.sh "$@")" + +if [[ $? -eq 0 ]]; then + if ! ~/.configs_pointer/bin/rename_and_move.sh "$@"; then + exit 1 + fi + printf '%s' "$newname" +else + exit 2 +fi diff --git a/vifm/vifmrc b/vifm/vifmrc index f3575b4..530686c 100644 --- a/vifm/vifmrc +++ b/vifm/vifmrc @@ -39,10 +39,8 @@ nnoremap s :sort nnoremap :!/usr/bin/env IS_VIFM_NEST='T' bash -l nnoremap :!/usr/bin/env IS_VIFM_NEST='T' bash -l -" Open cwd in finder -nnoremap ofinder :!open . - -nnoremap ogadd :!git add %c +" Rename file/dir under cursor to unix standards Ore[name] +nnoremap ore :exe 'goto "'.system("~/.configs_pointer/vifm/scripts/vifm_rename_and_move_file.sh ".expand('%c')).'"' " Logical conflict mappings " Navigate back from symlinks @@ -149,9 +147,6 @@ nnoremap m :sync %d "nnoremap 6j "vnoremap 6j -nnoremap orestore :!git restore %c -nnoremap oadd :!git add %c - " Make and navigate to a directory in the other pane command! cddir :sync! | exe 'wincmd w' | mkdir "%d/%a" | cd "%d/%a" | exe 'wincmd w'