Comments (4)
@weierophinney Thanks for the information! Your comment prompted me to add a $NB_BROWSER
variable that can be set instead of $BROWSER
, in case that's helpful.
from nb.
Thanks for the suggestion!
I looked into it a bit and it appears that the best first step is to respect the user's $BROWSER
environment variable, which can be set in .bashrc, .zshrc, or similar:
export BROWSER=lynx
This variable is not standard, but it is included in the Debian and Arch documentation. nb
should work when this is set to a browser command with or without options. nb
does not support more complex $BROWSER
values, like a "colon-delimited list of commands" mentioned in the Debian documentation.
So as of version 5.6.1, nb
now checks the environment for a $BROWSER
environment variable and uses the specified browser instead of always defaulting to w3m
. Currently it only fully supports w3m
and lynx
. If $BROWSER
is not set, it falls back to w3m
and then lynx
.
Note that this also makes it possible to easily specify a different browser for an individual command:
> BROWSER=lynx nb 12 peek
# opens the URL from bookmark 12 in lynx
> BROWSER=w3m nb 12 peek
# opens the URL from bookmark 12 in w3m
w3m
is still used to escape HTML entities from titles and descriptions when saving a bookmark. When w3m
is not available, the title and description are saved without escaping HTML entities. I feel that this is OK given that w3m
is a recommended dependency, the only platform I'm aware of that w3m
doesn't work on is WSL 1, and adding lynx
support for that particular operation doesn't seem critical since it's internal and not exposed to the user. I added TODO
comments indicating that these operations should become browser-agnostic when time permits.
A setting has not yet been added within nb
for the browser. I'd like to see how it goes just respecting the $BROWSER
environment variable. I'm trying to avoid adding too many lines to nb
and want to see what other settings might need to be added.
I'm going to close this as complete. If you have any feedback, please let me know.
I hope this helps!
from nb.
Leaving a note here in case anybody else comes across a similar issue I encountered.
I use ubuntu, and $BROWSER
is set to /usr/bin/x-www-browser
, which eventually resolves to the browser alternative you have set, which is generally your GUI browser. I wanted to instead use w3m by default so that I stay in the CLI. As such, I wrote the following function in my shell configuration:
nb () {
BROWSER=w3m nb "$@"
}
This works great. However...
Occasionally when in w3m, I want to open a link or the current page in my GUI browser (for example, if I have a link to an external site). w3m has command bindings for this (Esc M
and M
, respectively), and you can configure which browser to open (defaults to /usr/bin/sensible-browser
, which, again, eventually resolves to the GUI browser).
The problem? sensible-browser uses the $BROWSER
value, which means everything opens in w3m.
I found two ways to fix this:
- When in w3m, press "o" to open the options screen. Find the External browser setting, and set it to the specific binary of the browser you use.
- Since the above means that if you switch your default browser, w3m will still be opening your previous, the better way is to just clear the
$BROWSER
value when opening nb:nb () { BROWSER= nb "$@" }
This latter works perfectly, and is future-proof with any changes in your default browser.
from nb.
Works brilliantly! I've set NB_BROWSER
in my shell configuration, and now can remove the nb()
function definition entirely!
Thanks, @xwmx !
from nb.
Related Issues (20)
- Error with fish completion HOT 8
- `Accept-Encoding: *` can suppress bookmark content downloads HOT 2
- Add support for neorg file title? HOT 3
- Tasks in Metadata
- in-code `rm` may cause irritating verbose output when tab completion is used HOT 2
- Minor issue: nb sync UI updates broken, "homDone!" HOT 6
- Directory Tools updates for exa/eza, lsd & joshuto HOT 1
- Tag list and Search fails with filenames using brackets: `[` and `]` HOT 5
- Errors running `nb browse` and `nb edit` commands HOT 7
- [Feature Request] Custom option for pandoc when using nb browse HOT 2
- No error when git fails to add/commit HOT 1
- [Feature request] Automatic alternative NBRC_PATH
- `nb sync` does not work when run non-interactively HOT 3
- Some web page are not downloaded when bookmarking HOT 15
- Flag --edit locks nb systemwide until editor is closed HOT 3
- Pandoc runs from bash working dir rather than $nb working dir -- fails to render resources HOT 2
- Adding custom CSS to `nb browse` HOT 7
- Specify tool/utility for search in `nb browse` HOT 2
- host with mkdocs? are there other options?
- nb crashed and it does not open anymore HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nb.