sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

index.md (2708B)


      1 Right click to plumb
      2 ====================
      3 Pretty much like plan9's acme and plumber: right-click some selected text to
      4 send it to the plumbing program of your choosing:
      5 
      6 * open an URL in a browser
      7 * view an image, PDF, ...
      8 * jump from logs to editor, at the specified line/col
      9 * etc
     10 
     11 The shell current working directory is set by the shell via `OSC 7` (borrowed
     12 from vte, see `/etc/profile.d/vte.sh` if you have it installed).
     13 
     14 For zsh :
     15 	__vte_urlencode() (
     16 	    # This is important to make sure string manipulation is handled
     17 	    # byte-by-byte.
     18 	    LC_ALL=C
     19 	    str="$1"
     20 	    while [ -n "$str" ]; do
     21 	        safe="${str%%[!a-zA-Z0-9/:_\.\-\!\'\(\)~]*}"
     22 	        printf "%s" "$safe"
     23 	        str="${str#"$safe"}"
     24 	        if [ -n "$str" ]; then
     25 	            printf "%%%02X" "'$str"
     26 	            str="${str#?}"
     27 	        fi
     28 	    done
     29 	)
     30 
     31 	__vte_osc7 () {
     32 	    printf "\033]7;%s%s\a" "${HOSTNAME:-}" "$(__vte_urlencode "${PWD}")"
     33 	}
     34 
     35 	[ -n "$ZSH_VERSION" ] && precmd_functions+=(__vte_osc7)
     36 
     37 The patch itself only adds a `cwd` global and a button3 entry that will run a
     38 shell, change directory to cwd and run the plumber with the primary selection.
     39 Maybe I should use pass cwd as an argument too, like plan9 plumber does.
     40 
     41 The plumbing program can be defined via `config.h`: 
     42 
     43 	static char plumber[] = "plumb.sh";
     44 
     45 Download
     46 --------
     47 * [right\_click\_to\_plumb.diff](right_click_to_plumb.diff) (2017-09-11)
     48 
     49 Authors
     50 -------
     51 * [jerome](http://blog.jardinmagique.info) <jerome@gcu.info>
     52 
     53 A simpler plumb patch
     54 =====================
     55 The plumbing command is run in the working directory of the shell, with as
     56 parameter the text selected with the mouse.
     57 
     58 Configuration is done in config.h and an example is supplied in config.def.h:
     59 
     60 	static char *plumb_cmd = "plumb";
     61 
     62 I made this version since I had a hard time understanding how the OSC 7 stuff
     63 works and I preferred a full C implementation of a plumbing patch.
     64 
     65 Download
     66 --------
     67 * [plumb\_without\_shell\_OSC.diff](plumb_without_shell_OSC.diff) (2018-11-03)
     68 
     69 Authors
     70 -------
     71 * [john](http://roxor.me) <j@roxor.me>
     72 
     73 A simpler, more flexible plumb patch
     74 ====================================
     75 A further development on the previous patch to allow for specifying the command line
     76 
     77 	static char *plumb_cmd[] = {"plumb", "-m", NULL, NULL};
     78 
     79 My plumb utility takes on the stdin by default, and requires another option to 
     80 be passed input on the command line, so I made this to allow for that.  It can be
     81 applied on its own, without the other patches.  It replaces the first NULL with
     82 the current selection.
     83 
     84 Download
     85 --------
     86 * [simple_plumb.diff](simple_plumb.diff) (2020-04-10)
     87 
     88 Authors
     89 -------
     90 * [dallin](https://dallinjdahl.github.io/) <dallinjdahl@gmail.com>
     91