jarun / ddgr

:duck: DuckDuckGo from the terminal
GNU General Public License v3.0
2.94k stars 139 forks source link

Add interface to pass browser specific options (incognito mode etc.) #153

Closed Andrew15-5 closed 1 year ago

Andrew15-5 commented 1 year ago

I want to open the chosen link in private mode in Firefox, but I can't find any way to do this in the current version. The BROWSER environment variable is only for browser commands and not for theirs options/flags.

As I was writing this, I came up with a very simple workaround — using ­a script wrapper such as firefox-private:

#!/bin/sh
set -e
if ! command -v firefox > /dev/null 2>&1; then
  echo 'firefox: command not found' >&2
  exit 1
fi
exec firefox --private-window "$@"

And then can be used as:

alias ddgr='BROWSER=firefox-private ddgr'

But this approach requires to add/modify 2 files only for 1 browser. If one would want to make aliases for ddgr to open in different browsers, the number of files that are needed to be modified will increase.

jarun commented 1 year ago

The following works for me:

export BROWSER="firefox --private-window %s"