#!/usr/bin/env sh # AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry) # https://www.youtube.com/user/gotbletu # DESC: execute w3m commands via fzf # DEMO: https://youtu.be/drzMQuLE4BM # DEPEND: fzf gawk coreutils # REFF: inspired by NapoleonWils0n https://www.youtube.com/watch?v=dyXcYxZOa9M # REQD: 1. chmod +x ~/.w3m/cgi-bin/fnx_fzfmiru.cgi # 2. chmod +x ~/.w3m/cgi-bin/fnx_execute.cgi # 3. sed -i 's@cgi_bin.*@cgi_bin ~/.w3m/cgi-bin:/usr/lib/w3m/cgi-bin:/usr/local/libexec/w3m/cgi-bin@g' ~/.w3m/config # 4. $EDITOR ~/.w3m/keymap # keymap xx COMMAND "READ_SHELL ~/.w3m/cgi-bin/fnx_fzfmiru.cgi ; BACK ; GOTO file:/cgi-bin/fnx_execute.cgi ; BACK" # CLOG: # 2021-08-02 tmux if statement for popup/split/no terminal fnx_database() { # $ = built-in functions ; & = custom ; * = favorites cat <' fn_click_prev_arrow.cgi#@CLICK_PREV_ARROW&#-- Click previous page button '<' fn_closetab_stash.cgi#@CLOSE_TAB_STASH&#-- Close tab (Stash URL to ~/.w3m/RestoreTab.txt) fn_dict_curl.cgi#@DICT_WORD_CURL&#-- Online dictionary for word at cursor fn_display_borders.cgi#@BORDERS&#-- Toggle table boarders fn_display_image.cgi#@DISPLAY_IMAGE_TOGGLE&#-- Toggle display image fn_display_link_number.cgi#@LINK_NUMBER&#-- Toggle link number (hinting mode e.g press 3[ to jump to link 3) fn_edit_bookmark.cgi#@EDIT_BOOKMARK&#-- Edit bookmark fn_edit_config.cgi#@EDIT_CONFIG&#-- Edit W3M configuration fn_edit_keymap.cgi#@EDIT_KEYMAP&#-- Edit W3M keymap fn_edit_mailcap.cgi#@EDIT_MAILCAP&#-- Edit W3M mailcap fn_edit_menu.cgi#@EDIT_MENU&#-- Edit W3M context menu fn_edit_restoretab.cgi#@EDIT_RESTORETAB&#-- Edit W3M restoretab ~/.w3m/RestoreTab.txt fn_edit_searchengine.cgi#@EDIT_SEARCHENGINES&#-- Edit search engine alias ~/.w3m/cgi-bin/search_engines.cgi fn_edit_siteconf.cgi#@EDIT_SITECONF&#-- Edit W3M siteconf fn_edit_surfraw.cgi#@EDIT_SURFRAW&#-- Edit surfraw bookmark ~/.surfraw/bookmark fn_edit_urimethodmap.cgi#@EDIT_URIMETHODMAP&#-- Edit W3M urimethodmap fn_engine_duckduckgo.cgi#@ENGE_DDG&*#-- Search the web via duckduckgo fn_engine_geminispace.cgi#@ENGE_GEMSPC&#-- Search gemini capsules via geminispace fn_engine_google.cgi#@ENGE_GOOGLE&*#-- Search the web via google fn_engine_invidious.cgi#@ENGE_INVIDIOUS&#-- Search youtube videos via invidious fn_engine_1337x.cgi#@ENGE_1337X&*#-- Search 1337x for torrents fn_engine_piratebay.cgi#@ENGE_TPB&*#-- Search piratebay for torrents fn_engine_nyaasi.cgi#@ENGE_NYAASI&#-- Search nyaa for anime torrents fn_engine_xdcceu.cgi#@ENGE_XDCCEU&*#-- Search xdcceu for xdcc (irc dcc files) fn_engine_veronica2.cgi#@ENGE_V2&#-- Search gopherspace via veronica-2 fn_engine_wikipedia.cgi#@ENGE_WIKIPEDIA&#-- Search wikipedia for articles fn_engine_yahoo.cgi#@ENGE_YAHOO&#-- Search the web via yahoo fn_engine_commandlinefu.cgi#@ENGE_CMDFU&#-- Search for commandline one liners via commandlinefu fn_goto_tmux_clipboard.cgi#@GOTO_CLIP_TMUX&&#-- Paste URL and go (via tmux clipboard) fn_goto_w3m_clipboard.cgi#@GOTO_CLIP_W3M&#-- Paste URL and go (via W3M clipboard /tmp/clipbrd.txt) fn_goto_x11_clipboard.cgi#@GOTO_CLIP_X11&#-- Paste URL and go (via xsel X11 clipboard) fn_open_link_in_gui_browser.cgi#@GUI_BROWSER_LINK&#-- Open link at cursor in external browser ($BROWSER) fn_open_page_in_gui_browser.cgi#@GUI_BROWSER_URL&#-- Open page URL in external browser ($BROWSER) fn_readerview_rdrview.cgi#@RDRVIEW_RDRVIEW&*#-- Reader view using rdrview (c/c++) fn_readerview_readable.cgi#@RDRVIEW_READABLE&#-- Reader view using readability-cli (nodejs) fn_readerview_readability.cgi#@RDRVIEW_READABILITY&#-- Reader view using python-readability-lxml (python3) fn_restore_tab.cgi#@RESTORE_TAB&#-- Restore tab from ~/.w3m/RestoreTab.txt fn_show_input_line_editing_mode_key_binding.cgi#@LIST_EDIT_MODE_KEY&#-- Show input editing mode key binding fn_show_user_defined_key_binding.cgi#@LIST_DEFINED_KEY&*#-- Show user custom key binding fn_toggle_color.cgi#@COLOR&#-- Toggle color fn_toggle_line_number.cgi#@LINE_NUMBER&*#-- Toggle line number fn_treat_url_like_strings.cgi#@TREAT_URL&*#-- Toggle plain text to clickable link fn_user_agent_clear.cgi#@USER_AGENT_CLEAR&#-- Clear user agent string fn_user_agent_set.cgi#@USER_AGENT_SET&#-- Set user agent string fn_yank_current_link.cgi#@YANK_LINK&*#-- Copy link at cursor to clipboard fn_yank_page_url.cgi#@YANK_URL&*#-- Copy page URL to clipboard fn_save_session.cgi#@SAVE_SESSION&*#-- Save session and ask to quit (run 'w3mlastsession' command to restore) fn_tts_espeak_page.cgi#@TTS_ESPEAK_PAGE&*#-- Espeak-ng text to speech whole page (Press Ctrl+C to continue browsing) fn_tts_espeak_word.cgi#@TTS_ESPEAK_WORD&#-- Espeak-ng text to speech single word fn_tts_festival_page.cgi#@TTS_FESTIVAL_PAGE&#-- Festival text to speech whole page (Press Ctrl+C to continue browsing) fn_tts_festival_word.cgi#@TTS_FESTIVAL_WORD&#-- Festival text to speech single word fn_tts_svoxpico_page.cgi#@TTS_SVOXPICO_PAGE&#-- SVOX Pico text to speech whole page (Press Ctrl+C to continue browsing) fn_tts_svoxpico_word.cgi#@TTS_SVOXPICO_WORD&#-- SVOX Pico text to speech single word fn_tts_kill.cgi#@TTS_KILL&*#-- Killall text to speech playback in progress fn_diana_add.cgi#@DIANA_ADD&*#-- Add to aria2 daemon for downloading fn_diana_addpaused.cgi#@DIANA_ADDPAUSED&*#-- Add to aria2 daemon for downloading (paused state) fn_aria2p.cgi#@TUI_ARIA2P&#-- Aria2p TUI aria2 daemon download manager (python3) fn_aria2t.cgi#@TUI_ARIA2T&#-- Aria2t TUI aria2 daemon download manager (c/c++) http://wttr.in#@WWW_WTTR&#-- Check weather forecast https://text.npr.org#@WWW_NPR&#-- NPR latest news http://lite.cnn.io/en#@WWW_CNN&#-- Breaking news http://68k.news/#@WWW_68k&#-- Headlines from the future https://news.ycombinator.com#@WWW_HN&#-- Hacker news https://thepiratebay10.org/top/all#@WWW_TPB&#-- Piratebay top 100 torrents https://1337x.to/top-100#@WWW_1337X&#-- 1337x top 100 torrents https://raw.githubusercontent.com/tats/w3m/master/ChangeLog#@WWW_W3MCLOG&#-- W3M updated changelog https://github.com/tats/w3m/issues#@WWW_W3MISSUE&#-- W3M open issue https://www.reddit.com/r/w3m/.mobile#@WWW_W3M&#-- W3M subreddit https://www.reddit.com/r/commandline/.mobile#@WWW_CLI&#-- Commandline subreddit https://www.reddit.com/r/linux/.mobile#@WWW_GNU&#-- GNU/Linux subreddit gopher://bitreich.org/1/lawn#@WWW_LAWN&#-- Gopher list of popular gopherhole ~/Downloads#@DIR_DL&#-- Open ~/Downloads directory /media#@DIR_MEDIA&#-- Open /media directory EOF } # clear screen printf "\033c" w3m_fnx_clipboard=/tmp/w3m_fnx_clipboard.txt # not running tmux if [ "$TMUX_PANE" = "%0" ] || [ -z "$TMUX" ] || [ -z "$TERM_PROGRAM" ] ; then selection="$( fnx_database | sort -t '@' -k2 | column -t -s '#' | \ fzf -i -e --delimiter '@' --with-nth 2.. --prompt='fzf-miru [$func|&custom|*fav] (run a W3M command): ' \ --info=default --layout=reverse --tiebreak=index | \ awk '{print $1}' )" [ -z "$selection" ] && echo "" > "$w3m_fnx_clipboard" && exit # tmux -ge 3.2 popup elif [ "$TERM_PROGRAM" = tmux ] ; then selection="$( fnx_database | sort -t '@' -k2 | column -t -s '#' | \ fzf-tmux -p -w 80% -h 70% -i -e --delimiter '@' --with-nth 2.. --prompt='fzf-miru [$func|&custom|*fav] (run a W3M command): ' \ --info=default --layout=reverse --tiebreak=index | \ awk '{print $1}' )" [ -z "$selection" ] && echo "" > "$w3m_fnx_clipboard" && exit # tmux -lt 3.2 regular split elif [ -n "$TMUX" ] ; then selection="$( fnx_database | sort -t '@' -k2 | column -t -s '#' | \ fzf-tmux -i -e --delimiter '@' --with-nth 2.. --prompt='fzf-miru [$func|&custom|*fav] (run a W3M command): ' \ --info=default --layout=reverse --tiebreak=index | awk '{print $1}' )" [ -z "$selection" ] && echo "" > "$w3m_fnx_clipboard" && exit fi echo "$selection" > "$w3m_fnx_clipboard"