Update ranger simple scripts to work with tmux

This commit is contained in:
Thomas Dehaeze 2020-01-28 21:29:15 +01:00
parent 9877b248dc
commit f46c0586aa

View File

@ -18,10 +18,10 @@
:END: :END:
* Config * Config
:PROPERTIES: :PROPERTIES:
:header-args: :tangle ~/.config/ranger/rc.conf :header-args: :tangle ~/.config/ranger/rc.conf
:header-args+: :comments both :mkdirp yes :header-args+: :comments both :mkdirp yes
:END: :END:
** Options ** Options
#+BEGIN_SRC conf #+BEGIN_SRC conf
@ -225,14 +225,45 @@ alias travel scout -aefiklst
** Some Custom Keybindings ** Some Custom Keybindings
*** Extract *** Extract
#+BEGIN_SRC conf #+BEGIN_SRC conf
map ,x shell atool -x %f # map ,x shell atool -x %f
map ,x shell ~/.config/ranger/scripts/extract.sh %f
#+END_SRC #+END_SRC
**** Extract Script
:PROPERTIES:
:header-args: :tangle ~/.config/ranger/scripts/extract.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
if [ $TMUX ]; then
tmux split -v -l 2 atool -x $1 && tmux select-pane -U
else
atool -x $1
fi
#+end_src
*** Compress *** Compress
#+BEGIN_SRC conf #+BEGIN_SRC conf
map ,z shell apack %f.zip %f # map ,z shell apack %f.zip %f
map ,z shell ~/.config/ranger/scripts/compress.sh %f
#+END_SRC #+END_SRC
**** Compress Script
:PROPERTIES:
:header-args: :tangle ~/.config/ranger/scripts/compress.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
if [ $TMUX ]; then
tmux split -v -l 2 apack ${1%.*}.zip $1 && tmux select-pane -U
else
apack ${1%.*}.zip $1
fi
#+end_src
*** Delete first page of pdf *** Delete first page of pdf
#+BEGIN_SRC conf #+BEGIN_SRC conf
map ,d shell ~/scripts/pdf-delete-first-page.sh %f map ,d shell ~/scripts/pdf-delete-first-page.sh %f
@ -248,11 +279,26 @@ map ,z shell apack %f.zip %f
map ,gs shell emacsclient -create-frame --alternate-editor="" -n --eval '(magit-status)' map ,gs shell emacsclient -create-frame --alternate-editor="" -n --eval '(magit-status)'
#+END_SRC #+END_SRC
*** Upload with Tansfer.sh *** Upload with 0x0 (previously Tansfer.sh)
#+BEGIN_SRC conf #+BEGIN_SRC conf
map ,t shell curl --progress-bar --upload-file %f https://transfer.sh/$(basename $1) | xclip -in -selection clipboard; # map ,t shell curl --progress-bar --upload-file %f https://transfer.sh/$(basename $1) | xclip -in -selection clipboard;
map ,t shell ~/.config/ranger/scripts/upload.sh %f
#+END_SRC #+END_SRC
**** Upload Script
:PROPERTIES:
:header-args: :tangle ~/.config/ranger/scripts/upload.sh
:header-args+: :comments both :mkdirp yes
:header-args+: :shebang "#!/usr/bin/env bash"
:END:
#+begin_src bash
if [ $TMUX ]; then
tmux split -v -l 1 curl --progress-bar -F"file=@$1" https://0x0.st | xclip -in -selection clipboard && tmux select-pane -U
else
curl --progress-bar -F"file=@$1" https://0x0.st | xclip -in -selection clipboard;
fi
#+end_src
*** Open current folder with PCManFM *** Open current folder with PCManFM
#+begin_src conf #+begin_src conf
map ,o shell nohup pcmanfm %d & map ,o shell nohup pcmanfm %d &
@ -267,7 +313,7 @@ map ,z shell apack %f.zip %f
*** Basic *** Basic
#+BEGIN_SRC conf #+BEGIN_SRC conf
map Q quit! map Q quit!
map q quit map q eval fm.execute_console("shell tmux detach") if 'TMUX' in os.environ.keys() else fm.execute_console("quit")
copymap q ZZ ZQ copymap q ZZ ZQ
map R reload_cwd map R reload_cwd
@ -360,6 +406,7 @@ map ,z shell apack %f.zip %f
map ga cd ~/Cloud/administratif map ga cd ~/Cloud/administratif
map gm cd ~/Cloud/thesis map gm cd ~/Cloud/thesis
map gp cd ~/Pictures map gp cd ~/Pictures
map gT cd ~/.local/share/Trash/files
map gd cd ~/Downloads map gd cd ~/Downloads
map gc cd ~/.config/literate-dotfiles map gc cd ~/.config/literate-dotfiles
#+END_SRC #+END_SRC
@ -395,7 +442,7 @@ Should automatically close mimeopen after the program is chosen.
*** Filesystem Operations *** Filesystem Operations
#+BEGIN_SRC conf #+BEGIN_SRC conf
map = chmod map = chmod
#+END_SRC #+END_SRC
*** Drag and Drop *** Drag and Drop
@ -430,7 +477,7 @@ map = chmod
*** Delete and move files *** Delete and move files
#+BEGIN_SRC conf #+BEGIN_SRC conf
map dD console delete map dD shell -s trash-put %s
map dd cut map dd cut
map ud uncut map ud uncut
map da cut mode=add map da cut mode=add
@ -481,7 +528,6 @@ map = chmod
map <A-Right> tab_move 1 map <A-Right> tab_move 1
map <A-Left> tab_move -1 map <A-Left> tab_move -1
map gt tab_move 1 map gt tab_move 1
map gT tab_move -1
map gn tab_new ~ map gn tab_new ~
map uq tab_restore map uq tab_restore
map <a-1> tab_open 1 map <a-1> tab_open 1
@ -700,10 +746,10 @@ default_linemode devicons
#+END_SRC #+END_SRC
* Rifle * Rifle
:PROPERTIES: :PROPERTIES:
:header-args: :tangle ~/.config/ranger/rifle.conf :header-args: :tangle ~/.config/ranger/rifle.conf
:header-args+: :comments both :mkdirp yes :header-args+: :comments both :mkdirp yes
:END: :END:
#+BEGIN_SRC conf #+BEGIN_SRC conf
# This is the configuration file of "rifle", ranger's file executor/opener. # This is the configuration file of "rifle", ranger's file executor/opener.
@ -912,10 +958,10 @@ default_linemode devicons
#+END_SRC #+END_SRC
* Ranger Commands * Ranger Commands
:PROPERTIES: :PROPERTIES:
:header-args: :tangle ~/.config/ranger/commands.py :header-args: :tangle ~/.config/ranger/commands.py
:header-args+: :comments both :mkdirp yes :header-args+: :comments both :mkdirp yes
:END: :END:
** Import ** Import
#+begin_src python #+begin_src python
from ranger.api.commands import * from ranger.api.commands import *