From cbd2badd5f3def6efba38f1058792208ea893a90 Mon Sep 17 00:00:00 2001 From: Maxim Likhachev Date: Wed, 13 Nov 2019 18:41:41 +0300 Subject: [PATCH] vim, vifm: pdf renamer --- etc/soft/vifm/commands | 2 ++ etc/soft/vim/vim/+ftplugin/rename.vim | 19 +++++++++++++++++++ etc/soft/vim/vim/ftdetect/detect.vim | 2 ++ etc/soft/vim/vim/ftplugin/go/go.custom.vim | 1 + etc/soft/vim/vim/ftplugin/rename/rename.custom.vim | 1 + 5 files changed, 25 insertions(+) create mode 100644 etc/soft/vim/vim/+ftplugin/rename.vim create mode 120000 etc/soft/vim/vim/ftplugin/go/go.custom.vim create mode 120000 etc/soft/vim/vim/ftplugin/rename/rename.custom.vim diff --git a/etc/soft/vifm/commands b/etc/soft/vifm/commands index a509160..6861049 100644 --- a/etc/soft/vifm/commands +++ b/etc/soft/vifm/commands @@ -45,3 +45,5 @@ command config :nvim $MYVIFMRC command z !!zathura %c:p +command renamepdf !f() { for f in "$@"; do echo "\"$f\""; done }; cd %d; f %f | viper +'set ft=rename' +"let b:rename_dir=\"$(pwd)\"" | sed "s/^/mv /" | sh + diff --git a/etc/soft/vim/vim/+ftplugin/rename.vim b/etc/soft/vim/vim/+ftplugin/rename.vim new file mode 100644 index 0000000..a3360df --- /dev/null +++ b/etc/soft/vim/vim/+ftplugin/rename.vim @@ -0,0 +1,19 @@ +"-------------------------- +" Переименование PDF-файлов +"-------------------------- + +function! PdfTags(findstart, base) + if a:findstart + return col('.') + 1 + else + silent let res = map(systemlist("exiftool -Author -Title " . + \b:rename_dir . "/" . + \trim(getline('.')) . + \" 2>&- | cut -d : -f 2- | tr '\n' ' ' | sed 's/ / - /' "), + \"'\"' . trim(v:val) . '.pdf\"'") + return res + endif +endfun + +setlocal omnifunc=PdfTags + diff --git a/etc/soft/vim/vim/ftdetect/detect.vim b/etc/soft/vim/vim/ftdetect/detect.vim index eb51b21..742b92c 100644 --- a/etc/soft/vim/vim/ftdetect/detect.vim +++ b/etc/soft/vim/vim/ftdetect/detect.vim @@ -57,3 +57,5 @@ au BufRead,BufNewFile *.note setf note au BufRead,BufNewFile *.rsc set filetype=rsc +au BufNewFile,BufRead *.rename set filetype=rename + diff --git a/etc/soft/vim/vim/ftplugin/go/go.custom.vim b/etc/soft/vim/vim/ftplugin/go/go.custom.vim new file mode 120000 index 0000000..786d6a6 --- /dev/null +++ b/etc/soft/vim/vim/ftplugin/go/go.custom.vim @@ -0,0 +1 @@ +../../+ftplugin/go.vim \ No newline at end of file diff --git a/etc/soft/vim/vim/ftplugin/rename/rename.custom.vim b/etc/soft/vim/vim/ftplugin/rename/rename.custom.vim new file mode 120000 index 0000000..16b9542 --- /dev/null +++ b/etc/soft/vim/vim/ftplugin/rename/rename.custom.vim @@ -0,0 +1 @@ +../../+ftplugin/rename.vim \ No newline at end of file