#!/bin/zsh setopt no_unset extended_glob warn_create_global typeset -gA clipboards typeset -ga labels print_choices() { local label for label in $labels; do printf '%s » %s\n' $label ${clipboards[$label]//$'\n'/»} done } main() { s6-sudo /run/cmd.s link xpra.$USER xsession.${DISPLAY#:}.$USER run/exec/exec || exit $? local label content for label content in ${(0)"$(s6-sudo /run/inbox/xpra.ccx/run/exec/exec clip -0)"}; do labels+=( $label ) clipboards[$label]=$content done local choice choice=$(print_choices | dmenu -l $#labels -fn Terminus) || exit $? choice=${choice%% » *} printf "%s" $clipboards[$choice] } typeset -f -t main main "$@"