sites

mirror of git://git.suckless.org/sites
Log | Files | Refs

index.md (1976B)


      1 # Right click to plumb
      2 
      3 Pretty much like plan9's acme and plumber: right-click some selected text to send it to the plumbing program of your choosing:
      4 
      5 * open an URL in a browser
      6 * view an image, PDF, ...
      7 * jump from logs to editor, at the specified line/col
      8 * etc
      9 
     10 The shell current working directory is set by the shell via `OSC 7` (borrowed from vte, see `/etc/profile.d/vte.sh` if you have it installed).
     11 
     12 For zsh :
     13 
     14 		__vte_urlencode() (
     15 		  # This is important to make sure string manipulation is handled
     16 		  # byte-by-byte.
     17 		  LC_ALL=C
     18 		  str="$1"
     19 		  while [ -n "$str" ]; do
     20 			safe="${str%%[!a-zA-Z0-9/:_\.\-\!\'\(\)~]*}"
     21 			printf "%s" "$safe"
     22 			str="${str#"$safe"}"
     23 			if [ -n "$str" ]; then
     24 			  printf "%%%02X" "'$str"
     25 			  str="${str#?}"
     26 			fi
     27 		  done
     28 		)
     29 
     30 		__vte_osc7 () {
     31 		  printf "\033]7;%s%s\a" "${HOSTNAME:-}" "$(__vte_urlencode "${PWD}")"
     32 		}
     33 
     34 		[ -n "$ZSH_VERSION"  ] && precmd_functions+=(__vte_osc7)
     35 
     36 The patch itself only adds a `cwd` global and a button3 entry that will run a shell, change directory to cwd and run the plumber with the primary selection. Maybe I should use pass cwd as an argument too, like plan9 plumber does.
     37 
     38 The plumbing program can be defined via `config.h`: 
     39 
     40 		static char plumber[] = "plumb.sh";
     41 
     42 ## Download
     43 
     44 * [right_click_to_plumb.diff](right_click_to_plumb.diff) (2017-09-11)
     45 
     46 ## Authors
     47 
     48 * [jerome](http://blog.jardinmagique.info) <jerome@gcu.info>
     49 
     50 
     51 # A simpler plumb patch
     52 
     53 The plumbing command is run in the working directory of the shell, with as parameter the text selected with the mouse.
     54 
     55 Configuration is done in config.h and an example is supplied in config.def.h:
     56 
     57                 static char *plumb_cmd = "plumb";
     58 
     59 I made this version since I had a hard time understanding how the OSC 7 stuff works and I preferred a full C implementation of a plumbing patch.
     60 
     61 ## Download
     62 
     63 * [plumb_without_shell_OSC.diff](plumb_without_shell_OSC.diff) (2018-11-03)
     64 
     65 ## Authors
     66 
     67 * [john](http://roxor.me) <j@roxor.me>