Add some fzf commands to opend pdf files

Also define a PDF_VIEWER var for a default PDF tool.
This commit is contained in:
Jeremy Gardais 2019-01-08 14:13:54 +01:00
parent e42eead94e
commit 04e1cdc7c8
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
2 changed files with 58 additions and 1 deletions

7
zshenv
View File

@ -57,6 +57,13 @@ export LESS_TERMCAP_ue=$'\E[0m' # fin
DIRSTACKSIZE=10
export DIRSTACKSIZE
# Default PDF viewer
if [ $(command -v zathura) ]; then
PDF_VIEWER="zathura"
else
PDF_VIEWER="evince"
fi
# Permissions rw-r--r-- pour les fichiers crées
# et rwxr-xr-x pour les répertoires crées
umask 022

52
zshrc
View File

@ -368,7 +368,6 @@ alias -s gif='mirage '
alias -s mp4='smplayer '
alias -s avi='smplayer '
alias -s flv='smplayer '
alias -s pdf='evince '
alias -s log='tail -f'
alias -s conf='vim '
alias -s gz='gunzip '
@ -1253,6 +1252,57 @@ v() {
fi
}
# pdf - fuzzy open with "${PDF_VIEWER}" from current directory
# cd into the directory of the selected file
# open the selected file with "${PDF_VIEWER}"
pdf() {
local files
files=$(find ${1:-.} -iname "*.pdf" 2> /dev/null | fzf +m) &&
if [[ -n $files ]]
then
dir=$(dirname "${files}")
cd "${dir}"
file=$(basename "${files}")
"${PDF_VIEWER}" -- "${file}"
fi
}
# pdfe - fuzzy open with evince from current directory
# cd into the directory of the selected file
# open the selected file with evince
pdfe() {
local files
files=$(find ${1:-.} -iname "*.pdf" 2> /dev/null | fzf +m) &&
if [[ -n $files ]]
then
dir=$(dirname "${files}")
cd "${dir}"
file=$(basename "${files}")
evince -- "${file}"
fi
}
# pdfz - fuzzy open with zathura from current directory
# cd into the directory of the selected file
# open the selected file with zathura
pdfz() {
local files
files=$(find ${1:-.} -iname "*.pdf" 2> /dev/null | fzf +m) &&
if [[ -n $files ]]
then
dir=$(dirname "${files}")
cd "${dir}"
file=$(basename "${files}")
zathura -- "${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