Manage some libreoffice extensions with fzf

This commit is contained in:
gardouille 2019-01-18 16:14:03 +01:00
parent 04e1cdc7c8
commit 202da101e9
Signed by: gardouille
GPG Key ID: E759BAA22501AF32
1 changed files with 59 additions and 0 deletions

59
zshrc
View File

@ -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