From 690490ce7131050c9bef1a3161a246591862ccc8 Mon Sep 17 00:00:00 2001 From: Tristan Havelick Date: Tue, 10 Feb 2026 22:18:00 -0700 Subject: [PATCH] Set chawan as default browser and add mailcap integration - Set BROWSER env var to prefer chawan over other browsers - Enable chawan features: cookies, referer headers, auto-redirects - Add custom search with just-bangs-lite (C-k keybinding) - Add M-o keybinding to open current URL in default GUI browser - Add mailcap integration to open images with imv using curl pipe - Create imv-mailcap wrapper script for seamless image viewing Co-Authored-By: Claude Sonnet 4.5 --- bin/imv-mailcap | 3 +++ chawan/auto.mailcap | 3 +++ chawan/config.toml | 22 ++++++++++++++++++++++ chawan/setup.sh | 1 + zsh/core.zsh | 6 +++++- 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 bin/imv-mailcap create mode 100644 chawan/auto.mailcap diff --git a/bin/imv-mailcap b/bin/imv-mailcap new file mode 100755 index 0000000..69063c3 --- /dev/null +++ b/bin/imv-mailcap @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +# Pipe URL directly to imv +exec curl -s "$1" | imv - diff --git a/chawan/auto.mailcap b/chawan/auto.mailcap new file mode 100644 index 0000000..416f04d --- /dev/null +++ b/chawan/auto.mailcap @@ -0,0 +1,3 @@ +# Chawan auto-executed mailcap entries +# Images +image/*; imv-mailcap %u diff --git a/chawan/config.toml b/chawan/config.toml index 992da37..b444c88 100644 --- a/chawan/config.toml +++ b/chawan/config.toml @@ -8,6 +8,28 @@ scripting = true # Enable images images = true +# Enable cookies and save them to disk (REQUIRED for login functionality) +cookie = "save" + +# Enable referer header (some sites require this for security) +referer-from = true + +# Auto-accept redirects without confirmation +meta-refresh = "always" + [display] # Set image display mode (auto, sixel, or kitty) image-mode = "sixel" + +# Custom search engine using just-bangs-lite +[[omnirule]] +match = '^jb:' +substitute-url = '(x) => "https://tristanhavelick.com/just-bangs-lite/?q=" + encodeURIComponent(x.replace(/^jb:/, ""))' + +# Rebind C-k to use just-bangs-lite as default search +[page] +'C-k' = '() => pager.load("jb:")' + +# Open current URL in default browser (press Esc then o) +# Use single quotes to protect shell special chars, escape any single quotes in URL +'M-o' = "() => pager.extern(\"xdg-open '\" + String(pager.buffer.url).replace(/'/g, \"'\\\\''\" ) + \"'\")" diff --git a/chawan/setup.sh b/chawan/setup.sh index 3d7842f..8219e1b 100755 --- a/chawan/setup.sh +++ b/chawan/setup.sh @@ -3,3 +3,4 @@ # Create chawan config directory and symlink config mkdir -p "$HOME/.config/chawan" ln -svf "$DOTFILES_HOME/chawan/config.toml" "$HOME/.config/chawan/config.toml" +ln -svf "$DOTFILES_HOME/chawan/auto.mailcap" "$HOME/.config/chawan/auto.mailcap" diff --git a/zsh/core.zsh b/zsh/core.zsh index f8aae53..84e9360 100644 --- a/zsh/core.zsh +++ b/zsh/core.zsh @@ -45,7 +45,11 @@ elif command_exists nvim; then fi # Browser detection - use first available -if command_exists firefox; then +if command_exists cha; then + export BROWSER=cha +elif command_exists zen-browser; then + export BROWSER=zen-browser +elif command_exists firefox; then export BROWSER=firefox elif command_exists chrome; then export BROWSER=chrome