@@ -247,6 +247,7 @@ ${bold}Options${normal}
247247${bold} Actions${normal}
248248 ${bold} gui${normal} \t\tBrowse snippet and paste it in the focused window ${underline} (default)${normal}
249249 ${bold} cli${normal} \t\tlist snippet in cli mode, only copy snippet in the paste buffer
250+ ${bold} rofi${normal} \t\tlist snippet in cli mode for rofi input. Accept an argument with the chosen snippet to paste it.
250251 ${bold} edit${normal} \t\tBrowse snippet and edit it
251252 ${bold} add${normal} <name> \tAdd a new snippet
252253 ${bold} list${normal} \t\tlist snippet
@@ -315,10 +316,15 @@ cli() {
315316
316317list () {
317318 local type=" ${1:- f} "
318-
319+ local filter=(cat)
320+ if [[ " $type " == " icon" ]]; then
321+ type=' f'
322+ filter=(sed -re ' s_^([^/]*)/(.*)_&\x0icon\x1f\1_' )
323+ fi
319324 find -L . -type " $type " |
320325 grep -vE ' ^\.$|\.git|\.gitconfig|\.gitkeep|\.gitignore|\./\.pre-commit-config.yaml' |
321326 sed -e ' s!\.\/!!' |
327+ " ${filter[@]} " |
322328 sort
323329}
324330
@@ -359,7 +365,7 @@ _snippy_completion() {
359365 prev="${COMP_WORDS[COMP_CWORD-1]}"
360366
361367 opts="-h --help -v --version -s --sort -m --sorting-method"
362- actions="gui cli edit add list cat completion"
368+ actions="gui cli edit add list rofi cat completion"
363369
364370 # Complete option values
365371 case "${prev}" in
@@ -393,7 +399,7 @@ gui() {
393399 # shellcheck disable=SC2086
394400 set +o errexit
395401
396- snippet=$( list | sed -re ' s_^([^/]*)/(.*)_&\x0icon\x1f\1_ ' | rofi " ${rofi_args[@]} " -p ' ❯ ' )
402+ snippet=$( list ' icon ' | rofi " ${rofi_args[@]} " -p ' ❯ ' )
397403
398404 if [ $? -eq 10 ]; then
399405 script_content=true
@@ -561,7 +567,6 @@ run() {
561567 xsel --clipboard --input < " $tmpfile "
562568 fi
563569 fi
564-
565570 if [ " $paste " = true ]; then
566571 # Paste into the current application.
567572 if is_gui; then
@@ -626,6 +631,15 @@ main() {
626631 cli
627632 run false
628633 ;;
634+ ' rofi' )
635+ shift
636+ if (( $# > 0 )) ; then
637+ snippet=" $* "
638+ coproc run > /dev/null 2>&1
639+ exit 0
640+ fi
641+ list ' icon'
642+ ;;
629643 ' list' )
630644 list
631645 ;;
0 commit comments