From 202da101e987e737eccfaa33226ff11c3ca9809e Mon Sep 17 00:00:00 2001 From: Gardouille Date: Fri, 18 Jan 2019 16:14:03 +0100 Subject: [PATCH] Manage some libreoffice extensions with fzf --- zshrc | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/zshrc b/zshrc index 461e6dc..127b79a 100644 --- a/zshrc +++ b/zshrc @@ -355,6 +355,7 @@ alias -s txt='$PAGER ' alias -s odt='libreoffice --writer ' alias -s rtf='libreoffice --writer ' alias -s doc='libreoffice --writer ' +alias -s docx='libreoffice --writer ' alias -s ods='libreoffice --calc ' alias -s xls='libreoffice --calc ' alias -s html=$BROWSER @@ -1252,6 +1253,7 @@ v() { fi } +# PDF with fzf {{{ # pdf - fuzzy open with "${PDF_VIEWER}" from current directory # cd into the directory of the selected file # open the selected file with "${PDF_VIEWER}" @@ -1302,7 +1304,64 @@ pdfz() { zathura -- "${file}" fi } +# }}} +# LibreOffice with fzf {{{ +# odt - fuzzy open wordprocessor related files +# Look for some known extensions (odt, rtf, doc,…). +# cd into the directory of the selected file. +# Open in background the selected file with libreoffice-writer. +odt() { + local files + + files=$(find ${1:-.} -regextype posix-extended -regex ".*\.(odt|rtf|doc|docx)" 2> /dev/null | fzf +m) && + + if [[ -n $files ]] + then + dir=$(dirname "${files}") + cd -- "${dir}" + file=$(basename "${files}") + command libreoffice --writer "${file}" & + fi +} + +# ods - fuzzy open spreadsheet related files +# Look for some known extensions (ods, xls,…). +# cd into the directory of the selected file. +# Open in background the selected file with libreoffice-calc. +ods() { + local files + + files=$(find ${1:-.} -regextype posix-extended -regex ".*\.(ods|xls|xlsx)" 2> /dev/null | fzf +m) && + + if [[ -n $files ]] + then + dir=$(dirname "${files}") + cd -- "${dir}" + file=$(basename "${files}") + command libreoffice --calc "${file}" & + fi +} + +# odp - fuzzy open presentation related files +# Look for some known extensions (odp, ppt,…). +# cd into the directory of the selected file. +# Open in background the selected file with libreoffice-impress. +odp() { + local files + + files=$(find ${1:-.} -regextype posix-extended -regex ".*\.(odp|ppt|pptx)" 2> /dev/null | fzf +m) && + + if [[ -n $files ]] + then + dir=$(dirname "${files}") + cd -- "${dir}" + file=$(basename "${files}") + command libreoffice --impress "${file}" & + fi +} + +# }}} # zsh-syntax-highlighting {{{ ## Activate if plugin is available [ -f ~/repos/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ] && source ~/repos/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh