Skip to content

Instantly share code, notes, and snippets.

@tofran
Last active January 29, 2024 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tofran/dbee8010e222ad3591dc82d2a63a0d06 to your computer and use it in GitHub Desktop.
Save tofran/dbee8010e222ad3591dc82d2a63a0d06 to your computer and use it in GitHub Desktop.
Simle utility to fake Python's `webbroser` and be able to bypass code that relies on it when there's no browser on the system.
#!/bin/sh
#
# Simle utility to fake Python's `webbroser` (https://docs.python.org/3/library/webbrowser.html).
# Usefull for when no GUI is available. For example inside a Docker container.
#
# Copy paste this code the terminal:
export BROWSER="~/fake-browser.sh:$BROWSER"
echo 'echo "Fake browser called with: $@" && touch ~/fake-browser.log && echo "$@" >> ~/fake-browser.log' > ~/fake-browser.sh
chmod +x ~/fake-browser.sh
# That's it!
# Test your browser by running: ~/fake-browser.sh something
# It should output to the stdout and also ~/fake-browser.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment