From 2385ab9b4abbbfade3b516b91da175fa77c6a190 Mon Sep 17 00:00:00 2001 From: Thomas Dehaeze Date: Tue, 26 May 2020 10:35:01 +0200 Subject: [PATCH] Add rsync to ranger --- dotfiles/ranger.org | 56 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/dotfiles/ranger.org b/dotfiles/ranger.org index cf3123f..fe03725 100644 --- a/dotfiles/ranger.org +++ b/dotfiles/ranger.org @@ -17,6 +17,15 @@ #+HTML_HEAD: :END: +#+begin_quote +%f the highlighted file +%d the path of the current directory +%s the selected files in the current directory +%t all tagged files in the current directory +%c the full paths of the currently copied/cut files +%p the full paths of selected files +#+end_quote + * Config :PROPERTIES: :header-args: :tangle ~/.config/ranger/rc.conf @@ -201,7 +210,6 @@ Get Bibtex from PDF map ,b shell pdf2bib %f #+END_SRC - Delete first page of pdf #+BEGIN_SRC conf map ,d shell pdf-delete-first-page %f @@ -237,6 +245,11 @@ Print on Rnice map ,p shell print-rnice %f & #+END_SRC +Backup to NAS +#+BEGIN_SRC conf + map ,B shell ~/.config/ranger/scripts/backup-to-nas.sh %s & +#+END_SRC + ** Scripts *** Extract Script :PROPERTIES: @@ -267,6 +280,42 @@ Print on Rnice #+end_src +*** Backup to NAS +:PROPERTIES: +:header-args: :tangle ~/.config/ranger/scripts/backup-to-nas.sh +:header-args+: :comments both :mkdirp yes +:header-args+: :shebang "#!/usr/bin/env bash" +:END: + +- Arguments are the files to be backup to the NAS + +#+begin_src bash + if [ $TMUX ]; then + tmux split -v -l 2 rsync -a --info=progress2 --rsh='ssh -p10022' "$@" nas:/volume1/Data/Downloads/Backup/ && tmux select-pane -U + else + rsync -a --info=progress2 --rsh='ssh -p10022' "$@" nas:/volume1/Data/Downloads/Backup/ + fi +#+end_src + +*** Paste with Rsync +:PROPERTIES: +:header-args: :tangle ~/.config/ranger/scripts/paste-rsync.sh +:header-args+: :comments both :mkdirp yes +:header-args+: :shebang "#!/usr/bin/env bash" +:END: + +- First argument is the directory where to copy files +- All other arguments are files that are to be copied + +#+begin_src bash + if [ $TMUX ]; then + tmux split -v -l 1 rsync -a --info=progress2 ${@:2} $1 && tmux select-pane -U + else + rsync -a --info=progress2 ${@:2} $1 + fi +#+end_src + + ** Define keys for the browser *** Basic #+BEGIN_SRC conf @@ -406,6 +455,11 @@ Print on Rnice map pht paste_hardlinked_subtree #+END_SRC +Paste with Rsync +#+BEGIN_SRC conf + map pr shell ~/.config/ranger/scripts/paste-rsync.sh %d %c +#+END_SRC + *** Delete and move files #+BEGIN_SRC conf map dD shell -s trash-put %s