I'm used to the linux way of opening a PDF from the terminal. That is, via e.g. evince sample.pdf
. Command completion makes this fairly fast. In particular when there are many files with the same name but different endings (like after pdflatex compilations). From macports I have the bash-completion, but it is ineffective for the open
command in the sense that I have to cycle through all files until I get the PDF one. Is there another way of opening a PDF that allows to employ the bash-completion? Or a way to make open
ignore certain file types?
Terminal Commands – How to Open PDF from Terminal Using Command Completion
macportsterminal
Related Question
- Mac – Using MacPorts bash, tab completion no longer lists hidden / dot files
- MacOS – Terminal command to move a number of files containing brackets to another folder or trash
- Terminal open-command -a Flag – Why It’s Not Necessary for Some Software
- Terminal – Open New Tab from Current Terminal Using Command
Best Answer
open
is a generic file-opener-thing so a generic completion foropen
must match anythingopen
can open. One workaround is to invent a new command name,alias
it toopen
, and then specify that the new command should complete PDF files.You could then use
viewpdf
to tab-complete-open PDF files. However this is rather incomplete as it only matches filenames unqualified with any directory path. With more complexity:Which should be saved into a
bash
rc file.If you instead use the Z-Shell
zsh
the completion might look like