qutebrowser/misc/userscripts/dmenu_qutebrowser

49 lines
1.9 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
2019-02-23 06:34:17 +01:00
# Copyright 2015-2019 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
2015-04-24 22:04:27 +02:00
# Copyright 2015 Zach-Button <zachrey.button@gmail.com>
#
# This file is part of qutebrowser.
#
# qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
# Pipes history, quickmarks, and URL into dmenu.
#
# If run from qutebrowser as a userscript, it runs :open on the URL
# If not, it opens a new qutebrowser window at the URL
#
# Ideal for use with tabs_are_windows. Set a hotkey to launch this script, then:
# :bind o spawn --userscript dmenu_qutebrowser
#
# Use the hotkey to open in new tab/window, press 'o' to open URL in current tab/window
# You can simulate "go" by pressing "o<tab>", as the current URL is always first in the list
#
2015-05-12 07:49:53 +02:00
# I personally use "<Mod4>o" to launch this script. For me, my workflow is:
# Default keys Keys with this script
2015-04-28 19:02:45 +02:00
# O <Mod4>o
# o o
# go o<Tab>
2015-04-24 22:04:27 +02:00
# gO gC, then o<Tab>
2015-04-28 19:02:45 +02:00
# (This is unnecessarily long. I use this rarely, feel free to make this script accept parameters.)
#
2015-04-28 19:02:45 +02:00
[ -z "$QUTE_URL" ] && QUTE_URL='http://google.com'
url=$(echo "$QUTE_URL" | cat - "$QUTE_CONFIG_DIR/quickmarks" "$QUTE_DATA_DIR/history" | dmenu -l 15 -p qutebrowser)
2017-12-02 19:31:52 +01:00
url=$(echo "$url" | sed -E 's/[^ ]+ +//g' | grep -E "https?:" || echo "$url")
[ -z "${url// }" ] && exit
2015-04-28 19:02:45 +02:00
echo "open $url" >> "$QUTE_FIFO" || qutebrowser "$url"