0

I have a problem passing special parameters from a bash script to a browser URL bar.

I would like to open a PDF file on a certain page, and with a certain zoom factor, and at a certain position (relative to a page corner, I think that's called "focus") in Brave, from the command line.

I thought that should work like this:

$ brave-browser file:/home/user/foo.pdf#page=5&zoom=150,50,50

(the ",50,50" would be the "focus") but it doesn't. It just provokes an error message.

Copy/pasting the entire line with all the special characters manually to the URL bar works fine, but I would like to do that without the mouse or keyboard, from the CL. In other words, copying the string

file:/home/user/foo.pdf#page=5&zoom=150,50,50

and pasting that straight into the URL bar will open the file the way I want in Brave.

This shortened command works from the CL: $ brave-browser file:/home/user/foo.pdf#page=5 but adding the &zoom=150,50,50 provokes an error message from Brave.

I just can't get my head around how to format the rest of the line so that the file opens in the browser as intended (zoomed and focussed), when called from the CL.

I begin to wonder if that is possible at all.

I have tried everything that was suggested here: Shell script to open a URL and a couple of other ideas I had (mainly, creative use of quotation marks)

I also read this, but I am not sure if it refers to the same question - and the post is 11 years old. Was hoping that things changed: Can a website pass focus to the browsers url field?

Thanks a lot for any help!

Zorba
  • 23
  • 1
  • 3

1 Answers1

0

Just found out that all it takes is a backslash in front of the ampersand...

Strange: no matter how I do write that here, with the *** before and after the code, or without the three *** , I can never see the backslash in the post's preview!

browser file:/home/user/foo.pdf#page=5 \ &zoom=150,50,50

I have to type blanks before and after the hash to make it visible in this post as above. Looks wrong but this is the only way I can show what I mean. Also strange: the hash # works without the backslash \

Thanks, should someone have looked into this in the meantime!

Zorba
  • 23
  • 1
  • 3