#+TITLE: Yazi #+SETUPFILE: ./setup/org-setup-file.org * General configuration #+begin_src conf :tangle ~/.config/yazi/yazi.toml [preview] tab_size = 4 image_filter = "nearest" [opener] onlyoffice = [ { run = "onlyoffice-desktopeditors %s", block = false, desc = "Only-Office"}, ] nsxiv = [ { run = "nsxiv %s", block = false, desc = "nsxiv"}, ] f3d = [ { run = "f3d %s", block = false, desc = "F3D"}, ] inkscape = [ { run = "inkscape %s", block = false, desc = "Inkscape"}, ] emacs = [ { run = "emacsclient -c %s", block = false, desc = "Emacs"}, ] nvim = [ { run = "nvim %s", block = true, desc = "neovim"}, ] freecad = [ { run = "freecad %s", block = false, desc = "FreeCAD"}, ] qutebrowser = [ { run = "qutebrowser %s", block = false, desc = "Qutebrowser"}, ] ics-add = [ { run = "ics-add %s", block = false, desc = "Add ICS"}, ] xournal = [ { run = "xournalpp %s", block = false, desc = "Xournalpp"}, ] [open] prepend_rules = [ { url="*.step", use = "f3d" }, { url = "*.org", use = ["emacs", "nvim"] }, { mime = "text/plain", use = "nvim" }, { mime = "image/bmp", use = ["nsxiv", "inkscape"] }, { mime = "text/xml", use = "qutebrowser" }, { mime = "text/calendar", use = "ics-add" }, { mime = "application/pdf", use = ["open", "inkscape", "xournal"] }, { mime = "application/zip", url = "*.FCStd", use = "freecad" }, { mime = "application/zip", url = "*.3mf", use = "f3d" }, { mime = "application/octet-stream", url = "*.stl", use = "f3d" }, { mime = "application/octet-stream", url = "*.stp", use = "f3d" }, { mime = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", use = "onlyoffice" }, ] #+end_src * Keybindings configuration #+begin_src conf :tangle ~/.config/yazi/keymap.toml [[mgr.prepend_keymap]] on = [ "g", "w" ] run = "cd ~/Cloud/work-projects" desc = "Cd to work-projects" [[mgr.prepend_keymap]] on = [ "g", "p" ] run = "cd ~/Cloud/personnal" desc = "Cd to personnal" [[mgr.prepend_keymap]] on = [ "g", "P" ] run = "cd ~/Cloud/pictures/phone" desc = "Cd to pictures" [[mgr.prepend_keymap]] on = [ "g", "s" ] run = "cd ~/Cloud/pictures/screenshots" desc = "Cd to screenshots" [[mgr.prepend_keymap]] on = [ "g", "T" ] run = "cd ~/.local/share/Trash/files" desc = "Cd to trash" [[mgr.prepend_keymap]] on = [ "g", "m" ] run = "cd ~/Cloud/meetings" desc = "Cd to meetings" [[mgr.prepend_keymap]] on = [ "g", "D" ] run = "cd ~/Cloud/documents" desc = "Cd to documents" [[mgr.prepend_keymap]] on = "R" run = "rename --empty=stem --cursor=start" desc = "rename overwrite" [[mgr.prepend_keymap]] on = "q" run = "shell 'if [ -n \"$TMUX\" ]; then tmux detach; fi' --confirm" desc = "Quit Yazi" [[mgr.prepend_keymap]] on = "!" run = 'shell "$SHELL" --block --confirm' desc = "Open shell here" [[mgr.prepend_keymap]] on = "" run = ''' shell 'dragon-drop -a -x "$@"' --confirm ''' #+end_src #+begin_src conf :tangle ~/.config/yazi/keymap.toml [[mgr.prepend_keymap]] on = ["e", "o"] run = 'shell "nohup pcmanfm $(dirname \"$0\") &" --confirm' desc = "Open directory" [[mgr.prepend_keymap]] on = ["e", "x"] run = 'shell "~/.config/yazi/scripts/extract.sh \"$0\"" --confirm' desc = "Extract" [[mgr.prepend_keymap]] on = ["e", "z"] run = 'shell "~/.config/yazi/scripts/compress.sh \"$(basename $0)\"" --confirm' desc = "Compress" [[mgr.prepend_keymap]] on = ["e", "e"] run = 'shell "convert-file \"$0\"" --confirm' desc = "Convert File" [[mgr.prepend_keymap]] on = ["e", "b"] run = 'shell "~/.config/yazi/scripts/add-reference.sh \"$0\"" --confirm' desc = "Convert File" [[mgr.prepend_keymap]] on = ["e", "p"] run = 'shell "print-esrf \"$0\"" --confirm' desc = "Print" #+end_src * Color scheme configuration. #+begin_src conf :tangle ~/.config/yazi/theme.toml #+end_src * Scripts *** Extract DOI, create BibTeX and rename file :PROPERTIES: :header-args: :tangle ~/.config/yazi/scripts/add-reference.sh :header-args+: :comments both :mkdirp yes :header-args+: :shebang "#!/usr/bin/env bash" :END: #+begin_src bash add_reference () { doi=$(pdf2doi $1 | sed 's/^DOI *//' | sed 's/ \+.*//') # If empty DOI, ask manually if [ -z $doi ]; then doi=$(rofi -dmenu -p "DOI") fi # If DOI, add it to Emacs if [ ! -z $doi ]; then emacsclient --eval "(tdh-org-ref-import-pdf \"$doi\" \"$1\")" && \ dunstify --replace=49496 "BibTeX" "File copied." else dunstify --replace=49496 "BibTeX" "Failed to get DOI" fi } add_reference "$1" #+end_src *** Extract Script :PROPERTIES: :header-args: :tangle ~/.config/yazi/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 Script :PROPERTIES: :header-args: :tangle ~/.config/yazi/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