commit a6d27c97726730bb73f1e2946344ecb492fbe372 from: Alex Arx date: Fri Nov 15 13:50:00 2024 UTC add the igpm example commit - 49324589345f5ccb54c545f8376f73ea484ec3eb commit + a6d27c97726730bb73f1e2946344ecb492fbe372 blob - ade7bd124e1515e7886b6d37326201598c9fb1df blob + 547f24b38e6317541aa0fd94c9f4f04a192d66b3 --- Makefile +++ Makefile @@ -31,8 +31,8 @@ clean: dist: clean mkdir -p $(DIST) - cp -rf CHANGES COPYING Makefile README pm2gpm version.mk $(BIN) $(MAN) \ - $(DIST) + cp -rf CHANGES COPYING Makefile README examples/igpm pm2gpm version.mk \ + $(BIN) $(MAN) $(DIST) tar cf - $(DIST) | gzip >$(TARBALL) rm -rf $(DIST) blob - /dev/null blob + 372418686f1931995eb2d6be7e1dca9a342d4cdc (mode 755) --- /dev/null +++ examples/igpm @@ -0,0 +1,92 @@ +#!/bin/sh + +selector=${SELECTOR:-fzf} +justprint=false +allenable=true +tmux=tmux +primary=primary +clipboard=clipboard +out=out + +while getopts COPTcopt name; do + case $name in + C) clipboard= ;; + O) out= ;; + P) primary= ;; + T) tmux= ;; + [copt]) + if $allenable; then + allenable=false + tmux= + primary= + clipboard= + out= + fi + + case $name in + c) clipboard=clipboard ;; + o) out=out ;; + p) primary=primary ;; + t) tmux=tmux ;; + esac + ;; + ?) echo "usage: igpm [-COPTcopt] [file ...]" >&2; exit 1 ;; + esac +done +shift $((OPTIND - 1)) + +test -n "$TMUX" || tmux= +test -n "$DISPLAY" || { primary=; clipboard=; } + +clip="$tmux $primary $clipboard $out" +nclip=0 +for c in $clip; do nclip=$((nclip + 1)); done +[ $nclip -gt 0 ] || { echo "nowhere to copy" 2>&1; exit 1; } +[ $nclip -eq 1 ] || clip="$(printf %s\\n $clip | $selector)" + +case $clip in +tmux) + test "$tmux" || exit 1 + GPM_COPY_INCMD='tmux loadb -b _gpm -' + GPM_COPY_OUTCMD='tmux showb -b _gpm' + GPM_COPY_DELCMD='tmux deleteb -b _gpm' + ;; +primary) + test "$primary" || exit 1 + GPM_COPY_INCMD=xclip + GPM_COPY_OUTCMD='xclip -o' + GPM_COPY_DELCMD='xclip